libg722_1 0.0.1
defs.h
1/*
2 * g722_1 - a library for the G.722.1 and Annex C codecs
3 *
4 * defs.h
5 *
6 * Adapted by Steve Underwood <steveu@coppice.org> from the reference
7 * code supplied with ITU G.722.1, which is:
8 *
9 * (C) 2004 Polycom, Inc.
10 * All rights reserved.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 */
16
17#define MAX(a,b) (a > b ? a : b)
18#define MIN(a,b) (a < b ? a : b)
19
20#define FRAME_SIZE (MAX_FRAME_SIZE >> 1)
21
22#define DCT_LENGTH (MAX_DCT_LENGTH >> 1)
23
24#define NUM_CATEGORIES 8
25
26#define REGION_POWER_TABLE_SIZE 64
27#define REGION_POWER_TABLE_NUM_NEGATIVES 24
28
29#define NUM_CATEGORIZATION_CONTROL_BITS 4
30#define NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 16
31
32#define MAX_NUM_CATEGORIZATION_CONTROL_BITS 5
33#define MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 32
34
35/* region_size = (BLOCK_SIZE * 0.875)/NUMBER_OF_REGIONS; */
36#define REGION_SIZE 20
37
38#define NUMBER_OF_REGIONS 14
39#define MAX_NUMBER_OF_REGIONS 28
40
41/* This value has been changed for fixed point interop */
42#define ESF_ADJUSTMENT_TO_RMS_INDEX (9-2)
43
44#define MAX_DCT_LENGTH_LOG 7
45#define DCT_LENGTH_LOG 6
46
47#define CORE_SIZE 10
48
49#if defined(G722_1_USE_FIXED_POINT)
50
51#include "basop32.h"
52
53#define DCT_LENGTH_DIV_2 160
54#define DCT_LENGTH_DIV_4 80
55#define DCT_LENGTH_DIV_8 40
56#define DCT_LENGTH_DIV_16 20
57#define DCT_LENGTH_DIV_32 10
58#define DCT_LENGTH_DIV_64 5
59
60void adjust_abs_region_power_index(int16_t *absolute_region_power_index, int16_t *mlt_coefs, int16_t number_of_regions);
61
62int16_t samples_to_rmlt_coefs(const int16_t new_samples[],
63 int16_t history[],
64 int16_t coefs[],
65 int dct_length);
66
67void rmlt_coefs_to_samples(int16_t *coefs,
68 int16_t *old_samples,
69 int16_t *out_samples,
70 int dct_length,
71 int16_t mag_shift);
72
73void rmlt_coefs_to_samples(int16_t *coefs,
74 int16_t *old_samples,
75 int16_t *out_samples,
76 int dct_length,
77 int16_t mag_shift);
78
79void categorize(int16_t number_of_available_bits,
80 int16_t number_of_regions,
81 int16_t num_categorization_control_possibilities,
82 int16_t *rms_index,
83 int16_t *power_categories,
84 int16_t *category_balances);
85
86int16_t calc_offset(int16_t *rms_index, int16_t number_of_regions, int16_t available_bits);
87
88void comp_powercat_and_catbalance(int16_t *power_categories,
89 int16_t *category_balances,
90 int16_t *rms_index,
91 int16_t number_of_available_bits,
92 int16_t number_of_regions,
93 int16_t num_categorization_control_possibilities,
94 int16_t offset);
95
96void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length);
97
98void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length);
99
100#else
101
102#define PI 3.141592653589793238462
103
104#define ENCODER_SCALE_FACTOR 18318.0f
105
106#define REGION_SIZE_INVERSE (1.0f/20.0f)
107
108/* The MLT output is incorrectly scaled by the factor
109 product of ENCODER_SCALE_FACTOR and sqrt(160.)
110 This is now (9/30/96) 1.0/2^(4.5) or 1/22.627.
111 In the current implementation this product
112 must be an integer power of sqrt(2). The
113 integer power is ESF_ADJUSTMENT_TO_RMS_INDEX.
114 The -2 is to conform with the range defined in the spec. */
115
116/* Scale factor used to match fixed point model results. */
117#define INTEROP_RMLT_SCALE_FACTOR_7 22.0f
118#define INTEROP_RMLT_SCALE_FACTOR_14 33.0f
119
120void categorize(int number_of_regions,
121 int number_of_available_bits,
122 int rms_index[MAX_NUMBER_OF_REGIONS],
123 int power_categories[MAX_NUMBER_OF_REGIONS],
124 int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]);
125
126void samples_to_rmlt_coefs(const float new_samples[],
127 float old_samples[],
128 float coefs[],
129 int dct_length);
130
131void rmlt_coefs_to_samples(float coefs[],
132 float old_samples[],
133 float out_samples[],
134 int dct_length);
135
136void dct_type_iv(float input[], float output[], int dct_length);
137
138#endif
139
140int16_t get_rand(g722_1_rand_t *randobj);
141
142/*- End of file ------------------------------------------------------------*/
Definition g722_1/g722_1.h:66