libg722_1
0.0.1
|
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 * (C) 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 00017 #define MAX(a,b) (a > b ? a : b) 00018 #define MIN(a,b) (a < b ? a : b) 00019 00020 #define FRAME_SIZE (MAX_FRAME_SIZE >> 1) 00021 00022 #define DCT_LENGTH (MAX_DCT_LENGTH >> 1) 00023 00024 #define NUM_CATEGORIES 8 00025 00026 #define REGION_POWER_TABLE_SIZE 64 00027 #define REGION_POWER_TABLE_NUM_NEGATIVES 24 00028 00029 #define NUM_CATEGORIZATION_CONTROL_BITS 4 00030 #define NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 16 00031 00032 #define MAX_NUM_CATEGORIZATION_CONTROL_BITS 5 00033 #define MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 32 00034 00035 /* region_size = (BLOCK_SIZE * 0.875)/NUMBER_OF_REGIONS; */ 00036 #define REGION_SIZE 20 00037 00038 #define NUMBER_OF_REGIONS 14 00039 #define MAX_NUMBER_OF_REGIONS 28 00040 00041 /* This value has been changed for fixed point interop */ 00042 #define ESF_ADJUSTMENT_TO_RMS_INDEX (9-2) 00043 00044 #define MAX_DCT_LENGTH_LOG 7 00045 #define DCT_LENGTH_LOG 6 00046 00047 #define CORE_SIZE 10 00048 00049 #if defined(G722_1_USE_FIXED_POINT) 00050 00051 #include "basop32.h" 00052 00053 #define DCT_LENGTH_DIV_2 160 00054 #define DCT_LENGTH_DIV_4 80 00055 #define DCT_LENGTH_DIV_8 40 00056 #define DCT_LENGTH_DIV_16 20 00057 #define DCT_LENGTH_DIV_32 10 00058 #define DCT_LENGTH_DIV_64 5 00059 00060 void adjust_abs_region_power_index(int16_t *absolute_region_power_index, int16_t *mlt_coefs, int16_t number_of_regions); 00061 00062 int16_t samples_to_rmlt_coefs(const int16_t new_samples[], 00063 int16_t history[], 00064 int16_t coefs[], 00065 int dct_length); 00066 00067 void rmlt_coefs_to_samples(int16_t *coefs, 00068 int16_t *old_samples, 00069 int16_t *out_samples, 00070 int dct_length, 00071 int16_t mag_shift); 00072 00073 void rmlt_coefs_to_samples(int16_t *coefs, 00074 int16_t *old_samples, 00075 int16_t *out_samples, 00076 int dct_length, 00077 int16_t mag_shift); 00078 00079 void categorize(int16_t number_of_available_bits, 00080 int16_t number_of_regions, 00081 int16_t num_categorization_control_possibilities, 00082 int16_t *rms_index, 00083 int16_t *power_categories, 00084 int16_t *category_balances); 00085 00086 int16_t calc_offset(int16_t *rms_index, int16_t number_of_regions, int16_t available_bits); 00087 00088 void comp_powercat_and_catbalance(int16_t *power_categories, 00089 int16_t *category_balances, 00090 int16_t *rms_index, 00091 int16_t number_of_available_bits, 00092 int16_t number_of_regions, 00093 int16_t num_categorization_control_possibilities, 00094 int16_t offset); 00095 00096 void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length); 00097 00098 void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length); 00099 00100 #else 00101 00102 #define PI 3.141592653589793238462 00103 00104 #define ENCODER_SCALE_FACTOR 18318.0f 00105 00106 #define REGION_SIZE_INVERSE (1.0f/20.0f) 00107 00108 /* The MLT output is incorrectly scaled by the factor 00109 product of ENCODER_SCALE_FACTOR and sqrt(160.) 00110 This is now (9/30/96) 1.0/2^(4.5) or 1/22.627. 00111 In the current implementation this product 00112 must be an integer power of sqrt(2). The 00113 integer power is ESF_ADJUSTMENT_TO_RMS_INDEX. 00114 The -2 is to conform with the range defined in the spec. */ 00115 00116 /* Scale factor used to match fixed point model results. */ 00117 #define INTEROP_RMLT_SCALE_FACTOR_7 22.0f 00118 #define INTEROP_RMLT_SCALE_FACTOR_14 33.0f 00119 00120 void categorize(int number_of_regions, 00121 int number_of_available_bits, 00122 int rms_index[MAX_NUMBER_OF_REGIONS], 00123 int power_categories[MAX_NUMBER_OF_REGIONS], 00124 int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]); 00125 00126 void samples_to_rmlt_coefs(const float new_samples[], 00127 float old_samples[], 00128 float coefs[], 00129 int dct_length); 00130 00131 void rmlt_coefs_to_samples(float coefs[], 00132 float old_samples[], 00133 float out_samples[], 00134 int dct_length); 00135 00136 void dct_type_iv(float input[], float output[], int dct_length); 00137 00138 #endif 00139 00140 int16_t get_rand(g722_1_rand_t *randobj); 00141 00142 /*- End of file ------------------------------------------------------------*/