Commit f3059062 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'lib_dec_fxd' into 'main'

lib_dec.c converted to fixed point.

See merge request !50
parents 668f557d 4bd591a0
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -350,6 +350,7 @@
    <ClCompile Include="..\lib_dec\lead_deindexing.c" />
    <ClCompile Include="..\lib_dec\lead_deindexing_fx.c" />
    <ClCompile Include="..\lib_dec\lib_dec.c" />
    <ClCompile Include="..\lib_dec\lib_dec_fx.c" />
    <ClCompile Include="..\lib_dec\lp_exc_d.c" />
    <ClCompile Include="..\lib_dec\lp_exc_d_fx.c" />
    <ClCompile Include="..\lib_dec\lsf_dec.c" />
+3 −0
Original line number Diff line number Diff line
@@ -815,6 +815,9 @@
      <Filter>decoder_evs_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_sns_dec_fx.c" />
    <ClCompile Include="..\lib_dec\lib_dec_fx.c">
      <Filter>decoder_all_c</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_dec\ivas_stat_dec.h">
+5 −0
Original line number Diff line number Diff line
@@ -528,6 +528,7 @@ enum

#define FRAMES_PER_SEC                      50
#define INV_FRAME_PER_SEC_Q15               656
#define INV_FR_P_S_MX_PRM_SPL_SBFR_Q15      164
#define FRAME_SIZE_NS                       20000000L

#define ACELP_LOOK_NS                       8750000L
@@ -2934,5 +2935,9 @@ extern const Word16 Idx2Freq_Tbl[];

//tbs_vase.c
#define PRED_GAIN_E 8

#define FS_48K_IN_NS_Q31 103079
#define FS_32K_IN_NS_Q31 68719
#define FS_16K_IN_NS_Q31 34360
/* clang-format on */
#endif /* CNST_H */
+3 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
*******************************************************************************************************/

#include "lib_dec.h"
#ifndef IVAS_FLOAT_FIXED
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
@@ -3006,7 +3007,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure(

    return IVAS_ERR_OK;
}

#endif // !IVAS_FLOAT_FIXED


+318 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@

#include "common_api_types.h"
#include <stdbool.h>
#include "typedef.h"

/*---------------------------------------------------------------------*
 * Decoder enums
@@ -90,6 +91,7 @@ typedef ivas_error ( *JbmTraceFileWriterFn )( const void *data, void *writer );


/* clang-format off */
#ifndef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
 * Decoder function declarations
 *---------------------------------------------------------------------*/
@@ -404,6 +406,322 @@ void IVAS_DEC_PrintDisclaimer(
    void
);

#else
/*---------------------------------------------------------------------*
 * Decoder function declarations
 *---------------------------------------------------------------------*/

 /* Open, configure, close functions - should be called once per decoder lifetime */

 /*! r: error code */
ivas_error IVAS_DEC_Open(
  IVAS_DEC_HANDLE *phIvasDec,                 /* i/o: pointer to an IVAS decoder handle to be opened                          */
  IVAS_DEC_MODE mode                          /* i  : compatibility mode (EVS or IVAS)                                        */
);

/*! r: error code */
ivas_error IVAS_DEC_Configure(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const UWord32 sampleRate,                  /* i  : output sampling frequency                                               */
  const IVAS_AUDIO_CONFIG outputConfig,       /* i  : audio configuration                                                     */
  const Word16 tsmEnabled,                   /* i  : enable TSM                                                              */
  const IVAS_RENDER_FRAMESIZE renderFramesize,            /* i  : rendering frame size                       */
  const Word16 customLsOutputEnabled,        /* i  : enable custom loudspeaker setup handle                                  */
  const Word16 hrtfReaderEnabled,            /* i  : enable HRTF binary file input                                           */
  const Word16 enableHeadRotation,           /* i  : enable head rotation for binaural output                                */
  const Word16 enableExternalOrientation,    /* i  : enable external orientations                                            */
  const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i  : head orientation tracking type                                   */
  const Word16 renderConfigEnabled,          /* i  : enable Renderer config. file for binaural output                        */
  const Word16 Opt_non_diegetic_pan,         /* i  : diegetic or not                                                         */
  const float non_diegetic_pan_gain,          /* i  : non diegetic panning gain                                               */
  const Word16 Opt_dpid_on,                  /* i  : enable directivity pattern option                                       */
  const UWord16 acousticEnvironmentId,       /* i  : Acoustic environment ID                                                 */
  const Word16 delayCompensationEnabled      /* i  : enable delay compensation                                               */
);

void IVAS_DEC_Close(
  IVAS_DEC_HANDLE *phIvasDec                  /* i/o: pointer to IVAS decoder handle                                          */
);


/* Decoding functions - should be called with a configured decoder handle */

/*! r: error code */
ivas_error IVAS_DEC_FeedFrame_Serial(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  UWord16 *serial,                           /* i  : buffer containing serial input bitstream. Each bit should be stored as a single UWord16 value  */
  const UWord16 num_bits,                    /* i  : number of bits in input bitstream                                       */
  Word16 bfi                                 /* i  : bad frame indicator flag                                                */
);

/*! r: decoder error code */
ivas_error IVAS_DEC_GetSamples(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const Word16 nSamplesAsked,                /* i  : number of samples wanted by the caller                                  */
  Word16 *pcmBuf,                            /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels  */
  Word16 *nOutSamples,                       /* o  : number of samples per channel written to output buffer                  */
  bool *needNewFrame                          /* o  : indication that the decoder needs a new frame                           */
);


/*! r: error code */
ivas_error IVAS_DEC_GetObjectMetadata(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_ISM_METADATA *metadata,                /* o  : struct where metadata decoded in most recently decoded frame will be written */
  const UWord16 zero_flag,                   /* i  : if this flag is enabled, this function outputs a zero-initialized metadata struct */
  const UWord16 objectIdx                    /* i  : index of the queried object                                             */
);

/*! r: error code */
ivas_error IVAS_DEC_GetMasaMetadata(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o  : pointer to handle, which will be set to point to metadata from the most recently decoded frame */
  const UWord8 getFromJbmBuffer              /* i  : get metadata from a JBM buffer                                          */
);

/*! r: error code */
ivas_error IVAS_DEC_FeedHeadTrackData(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_QUATERNION orientation,                /* i  : head-tracking data, listener orientation                                */
  IVAS_VECTOR3 Pos,                           /* i  : listener position                                                       */
  const Word16 subframe_idx                  /* i  : subframe index                                                          */
);

/*! r: error code */
ivas_error IVAS_DEC_FeedRefRotData(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_QUATERNION rotation                    /* i  : reference rotation data                                                 */
);

/*! r: error code */
ivas_error IVAS_DEC_FeedRefVectorData(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const IVAS_VECTOR3 listenerPos,             /* i  : Listener position                                                       */
  const IVAS_VECTOR3 refPos                   /* i  : Reference position                                                      */
);

/*! r: error code */
ivas_error IVAS_DEC_FeedExternalOrientationData(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_QUATERNION orientation,                /* i  : external orientation data                                               */
  Word8 enableHeadRotation,                  /* i  : flag to enable head rotation for this frame                             */
  Word8 enableExternalOrientation,           /* i  : flag to enable external orientation for this frame                      */
  Word8 enableRotationInterpolation,         /* i  : flag to interpolate rotations from current and previous frames          */
  Word16 numFramesToTargetOrientation,       /* i  : number of frames until target orientation is reached                    */
  const Word16 subframe_idx                  /* i  : subframe index                                                          */
);

/*! r: error code */
ivas_error IVAS_DEC_VoIP_FeedFrame(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  UWord8 *au,                                /* i  : buffer containing input access unit                                     */
  const UWord16 auSize,                      /* i  : size of the access unit                                                 */
  const UWord16 rtpSequenceNumber,           /* i  : RTP sequence number (16 bits)                                           */
  const UWord32 rtpTimeStamp,                /* i  : RTP timestamp (32 bits)                                                 */
  const UWord32 rcvTime_ms,                  /* i  : receive time of the RTP packet in milliseconds                          */
  const bool qBit                             /* i  : Q bit for AMR-WB IO                                                     */
);

ivas_error IVAS_DEC_VoIP_SetScale(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const Word16 maxScaling,                   /* i  : maximum allowed TSM scale                                               */
  const Word16 scale                         /* i  : TSM scale to set                                                        */
);

ivas_error IVAS_DEC_TSM_SetQuality(
  IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle                                                         */
  const float quality       /* i  : target TSM quality                                                          */
);

/*! r: error code */
ivas_error IVAS_DEC_VoIP_GetSamples(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  UWord16 nSamplesPerChannel,                /* i  : number of samples per channel requested to be written to output buffer  */
  Word16 *pcmBuf,                            /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels  */
  const UWord32 systemTimestamp_ms           /* i  : current system timestamp                                                */
#ifdef SUPPORT_JBM_TRACEFILE
  , JbmTraceFileWriterFn jbmWriterFn,
  void* jbmWriter
#endif
);

ivas_error IVAS_DEC_Flush(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const Word16 nSamplesPerChannel,           /* i  : number of samples per channel requested to be written to output buffer  */
  Word16 *pcmBuf,                            /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels  */
  Word16 *nSamplesFlushed                    /* o  : number of samples flushed                                               */
);

/* Setter functions - apply changes to decoder configuration */

/*! r: error code */
ivas_error IVAS_DEC_EnableVoIP(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const Word16 jbmSafetyMargin,              /* i  : allowed delay reserve for JBM, in milliseconds                          */
  const IVAS_DEC_INPUT_FORMAT inputFormat     /* i  : format of the input bitstream                                           */
);


ivas_error IVAS_DEC_SetRenderFramesize(
  IVAS_DEC_HANDLE hIvasDec,               /* i/o: IVAS decoder handle   */
  const IVAS_RENDER_FRAMESIZE render_framesize /* i  : render framesize      */
);

ivas_error IVAS_DEC_GetRenderFramesize(
  IVAS_DEC_HANDLE hIvasDec,          /* i/o: IVAS decoder handle   */
  IVAS_RENDER_FRAMESIZE *render_framesize /* o  : render framesize      */
);

ivas_error IVAS_DEC_GetRenderFramesizeSamples(
  IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle          */
  Word16 *render_framesize /* o  : render framesize in samples  */
);

ivas_error IVAS_DEC_GetReferencesUpdateFrequency(
  IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle          */
  Word16 *update_frequency /* o  : update frequency             */
);

ivas_error IVAS_DEC_GetNumOrientationSubframes(
  IVAS_DEC_HANDLE hIvasDec,       /* i/o: IVAS decoder handle   */
  Word16 *num_subframes /* o  : render framesize      */
);

ivas_error IVAS_DEC_GetRenderFramesizeMs(
  IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle          */
  UWord32 *render_framesize /* o  : render framesize in samples  */
);


/* Getter functions - retrieve information from a decoder through a handle */

/*! r: error code */
ivas_error IVAS_DEC_GetNumObjects(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  UWord16 *numObjects                        /* o  : number of objects for which the decoder has been configured             */
);

/*! r: error code */
ivas_error IVAS_DEC_GetFormat(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_DEC_BS_FORMAT *format                  /* o  : format detected from bitstream fed to the decoder                       */
);

/*! r: error code */
ivas_error IVAS_DEC_GetOutputBufferSize(
  const IVAS_DEC_HANDLE hIvasDec,             /* i  : IVAS decoder handle                                                     */
  Word16 *outputBufferSize                   /* o  : total number of samples expected in the output buffer for current decoder configuration */
);

/*! r: error code */
ivas_error IVAS_DEC_GetNumOutputChannels(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  Word16 *numOutputChannels                  /* o  : number of PCM output channels                                           */
);

/*! r: error code */
ivas_error IVAS_DEC_FeedCustomLsData(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const IVAS_CUSTOM_LS_DATA hLsCustomData     /* i  : Custom loudspeaker setup data                                           */
);

/*! r: error code */
ivas_error IVAS_DEC_GetHrtfHandle(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_DEC_HRTF_HANDLE *hHrtfTD               /* o  : HRTF handle                                                             */
);

/*! r: error code */
ivas_error IVAS_DEC_GetHrtfCRendHandle(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF      /* o  : Set of HRTF handle                                                      */
);

ivas_error IVAS_DEC_GetHrtfFastConvHandle(
  IVAS_DEC_HANDLE hIvasDec,                    /* i/o: IVAS decoder handle                                                    */
  IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv /* o  : FASTCONV HRTF handle                                                   */
);

ivas_error IVAS_DEC_GetHrtfParamBinHandle(
  IVAS_DEC_HANDLE hIvasDec,                    /* i/o: IVAS decoder handle                                                    */
  IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin /* o  : Parametric binauralizer HRTF handle                                    */
);


/*! r: error code*/
ivas_error IVAS_DEC_GetRenderConfig(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const IVAS_RENDER_CONFIG_HANDLE hRCout      /* o  : Render config handle                                                    */
);

/*! r: error code*/
ivas_error IVAS_DEC_GetDefaultRenderConfig(
  IVAS_RENDER_CONFIG_HANDLE hRCout            /* o  : Render config handle                                                    */
);

/*! r: error code*/
ivas_error IVAS_DEC_FeedRenderConfig(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const IVAS_RENDER_CONFIG_DATA hRenderConfig /* i  : Render config data structure                                            */
);

/*! r: error code */
ivas_error IVAS_DEC_GetDelay(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  Word16 *nSamples,                          /* o  : decoder delay in samples                                                */
  Word32 *timeScale                          /* o  : time scale of the delay, equal to decoder output sampling rate          */
);

/*! r: error code */
ivas_error IVAS_DEC_HasDecodedFirstGoodFrame(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  bool *hasDecodedFirstGoodFrame              /* o  : flag indicating if the decoder has decoded a good frame since it was configured */
);

/*! r: error code */
ivas_error IVAS_DEC_GetPcmFrameSize(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  Word32 *pcmFrameSize                       /* o  : total size of the PCM output frame. This takes into account the number of output channels */
);

/*! r: true if decoder has no data in VoIP jitter buffer */
bool IVAS_DEC_VoIP_IsEmpty(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  const Word16 nSamplesAsked
);

ivas_error IVAS_DEC_VoIP_Get_CA_offset(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  Word16 *optimum_offset,
  Word16 *FEC_hi
);

#ifdef SUPPORT_JBM_TRACEFILE
ivas_error IVAS_DEC_GetJbmData(
  IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
  IVAS_JBM_TRACE_DATA *JbmTraceData           /* o  : JBM Trace data                                                          */
);
#endif

/* Utility functions */

/*! r: pointer to an error message string */
const char *IVAS_DEC_GetErrorMessage(
  ivas_error error                            /* i  : decoder error code enum                                                 */
);

void IVAS_DEC_PrintConfig(
  const IVAS_DEC_HANDLE hIvasDec,             /* i  : IVAS decoder handle                                                     */
  const bool quietModeEnabled,                /* i  : quiet mode flag: if true, reduces the amount of config info printed      */
  const bool voipMode
);


void IVAS_DEC_PrintDisclaimer(
  void
);
#endif // IVAS_FLOAT_FIXED

/* clang-format on */

#endif
Loading