defs.h

00001 /*
00002  * g722_1 - a library for the G.722.1 and Annex C codecs
00003  *
00004  * defs.h
00005  *
00006  * Adapted by Steve Underwood <steveu@coppice.org> from the reference
00007  * code supplied with ITU G.722.1, which is:
00008  *
00009  *   © 2004 Polycom, Inc.
00010  *   All rights reserved.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00015  *
00016  * $Id: defs.h,v 1.16 2008/10/01 15:31:10 steveu Exp $
00017  */
00018 
00019 #define MAX(a,b) (a > b  ?  a  :  b)
00020 #define MIN(a,b) (a < b  ?  a  :  b)
00021 
00022 #define FRAME_SIZE                                      (MAX_FRAME_SIZE >> 1)
00023 
00024 #define DCT_LENGTH                                      (MAX_DCT_LENGTH >> 1)
00025 
00026 #define NUM_CATEGORIES                                  8
00027 
00028 #define REGION_POWER_TABLE_SIZE                         64
00029 #define REGION_POWER_TABLE_NUM_NEGATIVES                24
00030 
00031 #define NUM_CATEGORIZATION_CONTROL_BITS                 4
00032 #define NUM_CATEGORIZATION_CONTROL_POSSIBILITIES        16
00033 
00034 #define MAX_NUM_CATEGORIZATION_CONTROL_BITS             5
00035 #define MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES    32
00036 
00037 /* region_size = (BLOCK_SIZE * 0.875)/NUMBER_OF_REGIONS; */
00038 #define REGION_SIZE                                     20
00039 
00040 #define NUMBER_OF_REGIONS                               14
00041 #define MAX_NUMBER_OF_REGIONS                           28
00042 
00043 /* This value has been changed for fixed point interop */
00044 #define ESF_ADJUSTMENT_TO_RMS_INDEX                     (9-2)
00045 
00046 #define MAX_DCT_LENGTH_LOG                              7
00047 #define DCT_LENGTH_LOG                                  6
00048 
00049 #define CORE_SIZE                                       10
00050 
00051 #if defined(G722_1_USE_FIXED_POINT)
00052 
00053 #include "basop32.h"
00054 
00055 #define DCT_LENGTH_DIV_2                                160
00056 #define DCT_LENGTH_DIV_4                                80
00057 #define DCT_LENGTH_DIV_8                                40
00058 #define DCT_LENGTH_DIV_16                               20
00059 #define DCT_LENGTH_DIV_32                               10
00060 #define DCT_LENGTH_DIV_64                               5
00061 
00062 void adjust_abs_region_power_index(int16_t *absolute_region_power_index, int16_t *mlt_coefs, int16_t number_of_regions);
00063 
00064 int16_t samples_to_rmlt_coefs(const int16_t new_samples[],
00065                               int16_t history[],
00066                               int16_t coefs[],
00067                               int dct_length);
00068 
00069 void rmlt_coefs_to_samples(int16_t *coefs,
00070                            int16_t *old_samples,
00071                            int16_t *out_samples,
00072                            int dct_length,
00073                            int16_t mag_shift);
00074 
00075 void rmlt_coefs_to_samples(int16_t *coefs,
00076                            int16_t *old_samples,
00077                            int16_t *out_samples,
00078                            int dct_length,
00079                            int16_t mag_shift);
00080 
00081 void categorize(int16_t number_of_available_bits,
00082                 int16_t number_of_regions,
00083                 int16_t num_categorization_control_possibilities,
00084                 int16_t *rms_index,
00085                 int16_t *power_categories,
00086                 int16_t *category_balances);
00087 
00088 int16_t calc_offset(int16_t *rms_index, int16_t number_of_regions, int16_t available_bits);
00089 
00090 void comp_powercat_and_catbalance(int16_t *power_categories,
00091                                   int16_t *category_balances,
00092                                   int16_t *rms_index,
00093                                   int16_t number_of_available_bits,
00094                                   int16_t number_of_regions,
00095                                   int16_t num_categorization_control_possibilities,
00096                                   int16_t offset);
00097 
00098 void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length);
00099 
00100 void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length);
00101 
00102 #else
00103 
00104 #define PI                                              3.141592653589793238462
00105 
00106 #define ENCODER_SCALE_FACTOR                            18318.0f
00107 
00108 #define REGION_SIZE_INVERSE                             (1.0f/20.0f)
00109 
00110 /* The MLT output is incorrectly scaled by the factor
00111    product of ENCODER_SCALE_FACTOR and sqrt(160.)
00112    This is now (9/30/96) 1.0/2^(4.5) or 1/22.627.
00113    In the current implementation this product
00114    must be an integer power of sqrt(2). The
00115    integer power is ESF_ADJUSTMENT_TO_RMS_INDEX.
00116    The -2 is to conform with the range defined in the spec. */
00117 
00118 /* Scale factor used to match fixed point model results. */
00119 #define INTEROP_RMLT_SCALE_FACTOR_7                     22.0f
00120 #define INTEROP_RMLT_SCALE_FACTOR_14                    33.0f
00121 
00122 void categorize(int number_of_regions,
00123                 int number_of_available_bits,
00124                 int rms_index[MAX_NUMBER_OF_REGIONS],
00125                 int power_categories[MAX_NUMBER_OF_REGIONS],
00126                 int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]);
00127 
00128 void samples_to_rmlt_coefs(const float new_samples[],
00129                            float old_samples[],
00130                            float coefs[],
00131                            int dct_length);
00132 
00133 void rmlt_coefs_to_samples(float coefs[],
00134                            float old_samples[],
00135                            float out_samples[],
00136                            int dct_length);
00137 
00138 void dct_type_iv(float input[], float output[], int dct_length);
00139 
00140 #endif
00141 
00142 int16_t get_rand(g722_1_rand_t *randobj);
00143 
00144 /*- End of file ------------------------------------------------------------*/

Generated on 16 Jul 2011 for libg722_1 by  doxygen 1.6.1