⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.h

📁 手机加密通话软件
💻 H
字号:
/* Copyright 2001,2002,2003 NAH6
 * All Rights Reserved
 *
 * Parts Copyright DoD, Parts Copyright Starium
 *
 */
/**************************************************************************
*                                                                         *
* INCLUDE FILE
*               main.h
*
* FUNCTION
*               CELP parameters and variables
*
**************************************************************************/

#ifndef __main_h__
#define __main_h__

/*#include <hal.h>*/
#include <alloc.h>
#include "fxpt.h"
#include "celp_export.h"


#ifdef _DEBUG
#define LOGFLOAT( a )	logfloat( a, #a )
#define LOGFIXED( n, a )	logfloat( (((double)a)/2) / (1L<<(n-1)), #a )
#define LOGFIXED0( a )	logfloat( (double)(a), #a )
#ifdef _MSC_VER
#include <crtdbg.h>
#define ASSERT _ASSERT
#else
#define ASSERT assert
#endif
void dumplog( );
void logfloat( double f, char *s );
void clearlog();
#else
#define LOGFLOAT( a )
#define LOGFIXED( n, a )
#define LOGFIXED0( a )
#define ASSERT( b )
#endif

#ifdef _DEBUG
#define DUMPARR(a,dig,l) {int iii;for(iii=0;iii<l;iii++)LOGFIXED(dig,a[iii]);}
#else
#define  DUMPARR(a,dig,l)
#endif

#ifdef _DEBUG
#define DUMPARR0(a,l) {int iii;for(iii=0;iii<l;iii++)LOGFIXED0(a[iii]);}
#else
#define  DUMPARR0(a,l)
#endif


/* Starium Build Defines */
#ifdef _DEBUG
#define CELP_PRINTF(a) printf##a
#else
#define CELP_PRINTF(a)
#endif

#define CELP_ABORT  abort
// static inline void celp_drain_abort (void) { hal_drain (); hal_abort (); }
#define CELP_CALLOC global_calloc


/* General Constants */

#define F_LEN           240     /* number of speech samples in frame    */
#define NUM_SF          4       /* number of subframes in frame         */
#define SF_LEN          60      /* number of speech samples in subframe */
#define CELP_BITS       144     /* number of bits for CELP parameters   */
#define CELP_BYTES      (CELP_BITS/8)

#define ORDER           10      /* order of LP analysis                 */

#define LAMBDA          0       /* HF correction scale factor           */
#define OMEGA           32576   /* BW expansion for LPC anal. (0.994127)*/
#define OMEGA32         2134871476L  /* BW expansion for LPC anal. (0.994127)*/
#define GAMMA           26214   /* BW expansion for perceptual weighting*/

#define RES_LEN         SF_LEN  /* # of residual samples in subframe    */

#define ANALYSIS        11      /* for distinguishing between routines  */
#define SYNTHESIS       22      /*   shared between anal. & synth.      */

#ifndef TRUE
#define TRUE            1
#endif
#ifndef FALSE
#define FALSE           0
#endif

/* Adaptive Codebook Constants */
#define MIN_DELAY       2560    /* minimum adaptive delay (in 8.7 fmt)  */
#define MAX_DELAY       18816   /* maximum adaptive delay (in 8.7 fmt)  */
#define MAX_ACB_TAP     3       /* number of acb taps (filter)          */
#define ACB_SIZE        ((MAX_DELAY/128) + SF_LEN)
#define MAX_NUM_ADAPT   256     /* maximum number of adaptive delays    */
#define MAX_A_LEN       60      /* maximum adaptive frame length        */
#define MAX_ABUF_LEN    229     /* max adaptive analysis buffer length  */
#define AGAIN_BITS1     8       /* adaptive gain coding bit allocation  */
#define AGAIN_BITS2     6       /* adaptive gain coding bit allocation  */
#define AGAIN_BITS3     5       /* adaptive gain coding bit allocation  */
#define AGAIN_BITS4     0       /* adaptive gain coding bit allocation  */
#define AGAIN_BITS5     0       /* adaptive gain coding bit allocation  */
#define NUM_FULL_ADELAYS 256    /* 2**AGAIN_BITS1 -- # of full search   */
                                /* pitch delays                         */
#define NUM_DELTA_ADELAYS 64    /* 2**AGAIN_BITS2 -- # of delta search  */
                                /* pitch delays                         */
#define B_PTR           ((MAX_DELAY/128) + 2*SF_LEN)

/*  Stochastic Codebook Constants */
#define MAX_STOCH_CB_SIZE 512   /* maximum stochastic code book size    */
                                /* (number of codewords)                */
#ifndef STOCH_CB_SIZE
#define STOCH_CB_SIZE   64     /* actual stochastic code book size     */
#endif

#define LOG             111

#define STOCH_GAIN_BITS 5       /* code book gain bit allocation        */
#define STOCH_QUAN_TYPE LOG     /* code book gain quantizer type        */
#define MAX_CW_VEC_LEN  60      /* maximum codeword vector length       */

/* Delay constants */
#define MAX_M1          20      /* values for longest delay calculation */
#define MAX_M2          19
#define MAX_WINDOW_WIDTH 12*MAX_M1 + 12*(MAX_M2+1)
#define MAX_NFRAC       5


/*  Quantization constants */
#define LSFTABLE_LENGTH ORDER
#define LSFTABLE_WIDTH  16

/*  Channel constants */
#define CLEAR   9000
#define RBER    9001
#define RBLER   9005
#define OTHER   9006

#define BINARY          0x011
#define HEX             0x111
#define BINARY_INT      0x101


#ifndef min
#define min(A,B)        ((A)<(B)?(A):(B))
#define max(A,B)        ((A)>(B)?(A):(B))
#endif


/* Length of truncated impulse response */
/* IR values past 30 are nearly zero */
/*
 *  This value was formerly defined in adapt.c.  - DH
 */
#define LEN_TRUNC_H     30


typedef struct  {
        fxpt_16 lsf[11];                /* 0.15 format */
        fxpt_16 AdaptiveDelay[4];       /* 8.7 format */
        fxpt_16 AdaptiveGain[4];        /* 1.14 format */
        int     StochasticIndex[4];
        fxpt_16 StochasticGain[4];      /* 11.4 format */
} TX_PARAM;

typedef struct  {
        int     lsf[10];
        int     AdaptiveDelay[4];
        int     AdaptiveGain[4];
        int     StochasticIndex[4];
        int     StochasticGain[4];
        int     Bishnu;
        int     Hamming;
        int     Sync;
} TX_BITS;

typedef struct  {
        int     WhoKnows;
        short   What;
        fxpt_32 ThisShouldBe;
} INTEGRITY;


#endif /* __main_h__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -