1
/***************************************************************************
3
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
4
** > Software Release 2.1 (2008-06)
5
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
7
** � 2004 Polycom, Inc.
9
** All rights reserved.
11
***************************************************************************/
13
/***************************************************************************
16
Purpose: Contains files used to implement the G.722.1 Annex C encoder
20
***************************************************************************/
22
/***************************************************************************
24
***************************************************************************/
33
/***************************************************************************
36
Syntax: void encoder(Word16 number_of_available_bits,
37
Word16 number_of_regions,
42
inputs: number_of_available_bits
47
outputs: out_words[MAX_BITS_PER_FRAME/16]
50
Description: Encodes the mlt coefs into out_words using G.722.1 Annex C
53
WMOPS: 7kHz | 24kbit | 32kbit
54
-------|--------------|----------------
56
-------|--------------|----------------
58
-------|--------------|----------------
60
14kHz | 24kbit | 32kbit | 48kbit
61
-------|--------------|----------------|----------------
62
AVG | 1.39 | 1.71 | 2.01
63
-------|--------------|----------------|----------------
64
MAX | 2.00 | 2.30 | 2.52
65
-------|--------------|----------------|----------------
67
***************************************************************************/
69
void encoder(Word16 number_of_available_bits,
70
Word16 number_of_regions,
76
Word16 num_categorization_control_bits;
77
Word16 num_categorization_control_possibilities;
78
Word16 number_of_bits_per_frame;
79
Word16 number_of_envelope_bits;
80
Word16 categorization_control;
82
Word16 absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
83
Word16 power_categories[MAX_NUMBER_OF_REGIONS];
84
Word16 category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES-1];
85
Word16 drp_num_bits[MAX_NUMBER_OF_REGIONS+1];
86
UWord16 drp_code_bits[MAX_NUMBER_OF_REGIONS+1];
87
Word16 region_mlt_bit_counts[MAX_NUMBER_OF_REGIONS];
88
UWord32 region_mlt_bits[4*MAX_NUMBER_OF_REGIONS];
89
Word16 mag_shift_offset;
93
/* initialize variables */
95
if (number_of_regions == NUMBER_OF_REGIONS)
97
num_categorization_control_bits = NUM_CATEGORIZATION_CONTROL_BITS;
99
num_categorization_control_possibilities = NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
104
num_categorization_control_bits = MAX_NUM_CATEGORIZATION_CONTROL_BITS;
106
num_categorization_control_possibilities = MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
110
number_of_bits_per_frame = number_of_available_bits;
113
for (region=0; region<number_of_regions; region++)
115
region_mlt_bit_counts[region] = 0;
119
/* Estimate power envelope. */
120
number_of_envelope_bits = compute_region_powers(mlt_coefs,
124
absolute_region_power_index,
127
/* Adjust number of available bits based on power envelope estimate */
128
temp = sub(number_of_available_bits,number_of_envelope_bits);
129
number_of_available_bits = sub(temp,num_categorization_control_bits);
131
/* get categorizations */
132
categorize(number_of_available_bits,
134
num_categorization_control_possibilities,
135
absolute_region_power_index,
139
/* Adjust absolute_region_category_index[] for mag_shift.
140
This assumes that REGION_POWER_STEPSIZE_DB is defined
141
to be exactly 3.010299957 or 20.0 times log base 10
142
of square root of 2. */
143
temp = shl_nocheck(mag_shift,1);
144
mag_shift_offset = add(temp,REGION_POWER_TABLE_NUM_NEGATIVES);
146
for (region=0; region<number_of_regions; region++)
148
absolute_region_power_index[region] = add(absolute_region_power_index[region],mag_shift_offset);
152
/* adjust the absolute power region index based on the mlt coefs */
153
adjust_abs_region_power_index(absolute_region_power_index,mlt_coefs,number_of_regions);
156
/* quantize and code the mlt coefficients based on categorizations */
157
vector_quantize_mlts(number_of_available_bits,
159
num_categorization_control_possibilities,
161
absolute_region_power_index,
164
&categorization_control,
165
region_mlt_bit_counts,
168
/* stuff bits into words */
169
bits_to_words(region_mlt_bits,
170
region_mlt_bit_counts,
174
categorization_control,
176
num_categorization_control_bits,
177
number_of_bits_per_frame);
181
/***************************************************************************
182
Function: bits_to_words
184
Syntax: bits_to_words(UWord32 *region_mlt_bits,
185
Word16 *region_mlt_bit_counts,
186
Word16 *drp_num_bits,
187
UWord16 *drp_code_bits,
189
Word16 categorization_control,
190
Word16 number_of_regions,
191
Word16 num_categorization_control_bits,
192
Word16 number_of_bits_per_frame)
195
Description: Stuffs the bits into words for output
197
WMOPS: 7kHz | 24kbit | 32kbit
198
-------|--------------|----------------
200
-------|--------------|----------------
202
-------|--------------|----------------
204
14kHz | 24kbit | 32kbit | 48kbit
205
-------|--------------|----------------|----------------
206
AVG | 0.12 | 0.15 | 0.19
207
-------|--------------|----------------|----------------
208
MAX | 0.14 | 0.17 | 0.21
209
-------|--------------|----------------|----------------
211
***************************************************************************/
212
void bits_to_words(UWord32 *region_mlt_bits,
213
Word16 *region_mlt_bit_counts,
214
Word16 *drp_num_bits,
215
UWord16 *drp_code_bits,
217
Word16 categorization_control,
218
Word16 number_of_regions,
219
Word16 num_categorization_control_bits,
220
Word16 number_of_bits_per_frame)
222
Word16 out_word_index = 0;
226
Word16 region_bit_count;
227
Word16 current_word_bits_left;
229
Word16 out_word_bits_free = 16;
230
UWord32 *in_word_ptr;
231
UWord32 current_word;
237
/* First set up the categorization control bits to look like one more set of region power bits. */
241
drp_num_bits[number_of_regions] = num_categorization_control_bits;
244
drp_code_bits[number_of_regions] = (UWord16)categorization_control;
247
/* These code bits are right justified. */
248
for (region=0; region <= number_of_regions; region++)
250
current_word_bits_left = drp_num_bits[region];
253
current_word = (UWord32)drp_code_bits[region];
256
j = sub(current_word_bits_left,out_word_bits_free);
261
temp = extract_l(L_shr_nocheck(current_word,j));
262
out_word = add(out_word,temp);
264
out_words[out_word_index++] = out_word;
267
out_word_bits_free = 16;
270
out_word_bits_free = sub(out_word_bits_free,j);
272
acca = (current_word << out_word_bits_free);
273
out_word = extract_l(acca);
279
acca = (current_word << j);
280
accb = L_deposit_l(out_word);
281
acca = L_add(accb,acca);
282
out_word = extract_l(acca);
284
out_word_bits_free = sub(out_word_bits_free,current_word_bits_left);
288
/* These code bits are left justified. */
290
for (region=0;region<number_of_regions; region++)
292
accb = L_deposit_l(out_word_index);
293
accb = L_shl_nocheck(accb,4);
294
accb = L_sub(accb,number_of_bits_per_frame);
298
temp = shl_nocheck(region,2);
299
in_word_ptr = ®ion_mlt_bits[temp];
300
region_bit_count = region_mlt_bit_counts[region];
303
temp = sub(32,region_bit_count);
306
current_word_bits_left = region_bit_count;
308
current_word_bits_left = 32;
310
current_word = *in_word_ptr++;
312
acca = L_deposit_l(out_word_index);
313
acca = L_shl_nocheck(acca,4);
314
acca = L_sub(acca,number_of_bits_per_frame);
316
/* from while loop */
320
while ((region_bit_count > 0) && (acca < 0))
322
/* from while loop */
327
temp = sub(current_word_bits_left,out_word_bits_free);
331
temp = sub(32,out_word_bits_free);
332
accb = LU_shr(current_word,temp);
333
slice = (UWord16)extract_l(accb);
335
out_word = add(out_word,slice);
338
current_word <<= out_word_bits_free;
340
current_word_bits_left = sub(current_word_bits_left,out_word_bits_free);
341
out_words[out_word_index++] = extract_l(out_word);
347
out_word_bits_free = 16;
352
temp = sub(32,current_word_bits_left);
353
accb = LU_shr(current_word,temp);
354
slice = (UWord16)extract_l(accb);
356
temp = sub(out_word_bits_free,current_word_bits_left);
358
accb = slice << temp;
359
acca = L_deposit_l(out_word);
360
acca = L_add(acca,accb);
361
out_word = extract_l(acca);
362
out_word_bits_free = sub(out_word_bits_free,current_word_bits_left);
364
current_word_bits_left = 0;
369
if (current_word_bits_left == 0)
371
current_word = *in_word_ptr++;
372
region_bit_count = sub(region_bit_count,32);
374
/* current_word_bits_left = MIN(32,region_bit_count); */
375
temp = sub(32,region_bit_count);
378
current_word_bits_left = region_bit_count;
380
current_word_bits_left = 32;
383
acca = L_deposit_l(out_word_index);
384
acca = L_shl_nocheck(acca,4);
385
acca = L_sub(acca,number_of_bits_per_frame);
387
accb = L_deposit_l(out_word_index);
388
accb = L_shl_nocheck(accb,4);
389
accb = L_sub(accb,number_of_bits_per_frame);
393
/* Fill out with 1's. */
399
current_word = 0x0000ffff;
402
temp = sub(16,out_word_bits_free);
403
acca = LU_shr(current_word,temp);
404
slice = (UWord16)extract_l(acca);
406
out_word = add(out_word,slice);
407
out_words[out_word_index++] = out_word;
413
out_word_bits_free = 16;
416
acca = L_deposit_l(out_word_index);
417
acca = L_shl_nocheck(acca,4);
418
acca = L_sub(acca,number_of_bits_per_frame);
421
/***************************************************************************
422
Function: adjust_abs_region_power_index
424
Syntax: adjust_abs_region_power_index(Word16 *absolute_region_power_index,
426
Word16 number_of_regions)
429
*absolute_region_power_index
432
outputs: *absolute_region_power_index
434
Description: Adjusts the absolute power index
437
WMOPS: 7kHz | 24kbit | 32kbit
438
-------|--------------|----------------
440
-------|--------------|----------------
442
-------|--------------|----------------
444
14kHz | 24kbit | 32kbit | 48kbit
445
-------|--------------|----------------|----------------
446
AVG | 0.03 | 0.03 | 0.03
447
-------|--------------|----------------|----------------
448
MAX | 0.14 | 0.14 | 0.14
449
-------|--------------|----------------|----------------
451
***************************************************************************/
452
void adjust_abs_region_power_index(Word16 *absolute_region_power_index,Word16 *mlt_coefs,Word16 number_of_regions)
461
for (region=0; region<number_of_regions; region++)
463
n = sub(absolute_region_power_index[region],39);
464
n = shr_nocheck(n,1);
469
temp = extract_l(L_mult0(region,REGION_SIZE));
471
raw_mlt_ptr = &mlt_coefs[temp];
473
for (i=0; i<REGION_SIZE; i++)
475
acca = L_shl_nocheck(*raw_mlt_ptr,16);
476
acca = L_add(acca,32768L);
477
acca = L_shr_nocheck(acca,n);
478
acca = L_shr_nocheck(acca,16);
479
*raw_mlt_ptr++ = extract_l(acca);
482
temp = shl_nocheck(n,1);
483
temp = sub(absolute_region_power_index[region],temp);
484
absolute_region_power_index[region] = temp;
490
/***************************************************************************
491
Function: compute_region_powers
493
Syntax: Word16 compute_region_powers(Word16 *mlt_coefs,
495
Word16 *drp_num_bits,
496
UWord16 *drp_code_bits,
497
Word16 *absolute_region_power_index,
498
Word16 number_of_regions)
499
mlt_coefs[DCT_LENGTH];
501
drp_num_bits[MAX_NUMBER_OF_REGIONS];
502
drp_code_bits[MAX_NUMBER_OF_REGIONS];
503
absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
506
Description: Computes the power for each of the regions
509
WMOPS: 7kHz | 24kbit | 32kbit
510
-------|--------------|----------------
512
-------|--------------|----------------
514
-------|--------------|----------------
516
14kHz | 24kbit | 32kbit | 48kbit
517
-------|--------------|----------------|----------------
518
AVG | 0.20 | 0.20 | 0.20
519
-------|--------------|----------------|----------------
520
MAX | 0.29 | 0.29 | 0.29
521
-------|--------------|----------------|----------------
523
***************************************************************************/
525
Word16 compute_region_powers(Word16 *mlt_coefs,
527
Word16 *drp_num_bits,
528
UWord16 *drp_code_bits,
529
Word16 *absolute_region_power_index,
530
Word16 number_of_regions)
534
Word32 long_accumulator;
539
Word16 differential_region_power_index[MAX_NUMBER_OF_REGIONS];
540
Word16 number_of_bits;
548
input_ptr = mlt_coefs;
549
for (region=0; region<number_of_regions; region++)
551
long_accumulator = L_deposit_l(0);
553
for (j=0; j<REGION_SIZE; j++)
555
itemp1 = *input_ptr++;
557
long_accumulator = L_mac0(long_accumulator,itemp1,itemp1);
563
acca = (long_accumulator & 0x7fff0000L);
570
long_accumulator = L_shr_nocheck(long_accumulator,1);
572
acca = (long_accumulator & 0x7fff0000L);
575
power_shift = add(power_shift,1);
578
acca = L_sub(long_accumulator,32767);
580
temp = add(power_shift,15);
584
while ((acca <= 0) && (temp >= 0))
590
long_accumulator = L_shl_nocheck(long_accumulator,1);
591
acca = L_sub(long_accumulator,32767);
593
temp = add(power_shift,15);
595
long_accumulator = L_shr_nocheck(long_accumulator,1);
596
/* 28963 corresponds to square root of 2 times REGION_SIZE(20). */
597
acca = L_sub(long_accumulator,28963);
601
power_shift = add(power_shift,1);
603
acca = L_deposit_l(mag_shift);
604
acca = L_shl_nocheck(acca,1);
605
acca = L_sub(power_shift,acca);
606
acca = L_add(35,acca);
607
acca = L_sub(acca,REGION_POWER_TABLE_NUM_NEGATIVES);
608
absolute_region_power_index[region] = extract_l(acca);
612
/* Before we differentially encode the quantized region powers, adjust upward the
613
valleys to make sure all the peaks can be accurately represented. */
614
temp = sub(number_of_regions,2);
616
for (region = temp; region >= 0; region--)
618
temp1 = sub(absolute_region_power_index[region+1],DRP_DIFF_MAX);
619
temp2 = sub(absolute_region_power_index[region],temp1);
623
absolute_region_power_index[region] = temp1;
628
/* The MLT is currently scaled too low by the factor
629
ENCODER_SCALE_FACTOR(=18318)/32768 * (1./sqrt(160).
630
This is the ninth power of 1 over the square root of 2.
631
So later we will add ESF_ADJUSTMENT_TO_RMS_INDEX (now 9)
632
to drp_code_bits[0]. */
634
/* drp_code_bits[0] can range from 1 to 31. 0 will be used only as an escape sequence. */
635
temp1 = sub(1,ESF_ADJUSTMENT_TO_RMS_INDEX);
636
temp2 = sub(absolute_region_power_index[0],temp1);
640
absolute_region_power_index[0] = temp1;
644
temp1 = sub(31,ESF_ADJUSTMENT_TO_RMS_INDEX);
647
* The next line was corrected in Release 1.2
650
temp2 = sub(absolute_region_power_index[0], temp1);
654
absolute_region_power_index[0] = temp1;
658
differential_region_power_index[0] = absolute_region_power_index[0];
667
drp_code_bits[0] = (UWord16)add(absolute_region_power_index[0],ESF_ADJUSTMENT_TO_RMS_INDEX);
670
/* Lower limit the absolute region power indices to -8 and upper limit them to 31. Such extremes
671
may be mathematically impossible anyway.*/
672
for (region=1; region<number_of_regions; region++)
674
temp1 = sub(-8,ESF_ADJUSTMENT_TO_RMS_INDEX);
675
temp2 = sub(absolute_region_power_index[region],temp1);
679
absolute_region_power_index[region] = temp1;
683
temp1 = sub(31,ESF_ADJUSTMENT_TO_RMS_INDEX);
684
temp2 = sub(absolute_region_power_index[region],temp1);
688
absolute_region_power_index[region] = temp1;
693
for (region=1; region<number_of_regions; region++)
695
j = sub(absolute_region_power_index[region],absolute_region_power_index[region-1]);
696
temp = sub(j,DRP_DIFF_MIN);
702
j = sub(j,DRP_DIFF_MIN);
704
differential_region_power_index[region] = j;
707
temp = add(absolute_region_power_index[region-1],differential_region_power_index[region]);
708
temp = add(temp,DRP_DIFF_MIN);
709
absolute_region_power_index[region] = temp;
712
number_of_bits = add(number_of_bits,differential_region_power_bits[region][j]);
713
drp_num_bits[region] = differential_region_power_bits[region][j];
715
drp_code_bits[region] = differential_region_power_codes[region][j];
719
return (number_of_bits);
722
/***************************************************************************
723
Function: vector_quantize_mlts
725
Syntax: void vector_quantize_mlts(number_of_available_bits,
727
num_categorization_control_possibilities,
729
absolute_region_power_index,
732
p_categorization_control,
733
region_mlt_bit_counts,
736
Word16 number_of_available_bits;
737
Word16 number_of_regions;
738
Word16 num_categorization_control_possibilities;
739
Word16 mlt_coefs[DCT_LENGTH];
740
Word16 absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
741
Word16 power_categories[MAX_NUMBER_OF_REGIONS];
742
Word16 category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES-1];
743
Word16 *p_categorization_control;
744
Word16 region_mlt_bit_counts[MAX_NUMBER_OF_REGIONS];
745
Word32 region_mlt_bits[4*MAX_NUMBER_OF_REGIONS];
747
Description: Scalar quantized vector Huffman coding (SQVH)
750
WMOPS: 7kHz | 24kbit | 32kbit
751
-------|--------------|----------------
753
-------|--------------|----------------
755
-------|--------------|----------------
757
14kHz | 24kbit | 32kbit | 48kbit
758
-------|--------------|----------------|----------------
759
AVG | 0.62 | 0.90 | 1.11
760
-------|--------------|----------------|----------------
761
MAX | 1.16 | 1.39 | 1.54
762
-------|--------------|----------------|----------------
764
***************************************************************************/
766
void vector_quantize_mlts(Word16 number_of_available_bits,
767
Word16 number_of_regions,
768
Word16 num_categorization_control_possibilities,
770
Word16 *absolute_region_power_index,
771
Word16 *power_categories,
772
Word16 *category_balances,
773
Word16 *p_categorization_control,
774
Word16 *region_mlt_bit_counts,
775
UWord32 *region_mlt_bits)
781
Word16 total_mlt_bits = 0;
787
/* Start in the middle of the categorization control range. */
788
temp = shr_nocheck(num_categorization_control_possibilities,1);
790
for (*p_categorization_control = 0; *p_categorization_control < temp; (*p_categorization_control)++)
792
region = category_balances[*p_categorization_control];
794
power_categories[region] = add(power_categories[region],1);
798
for (region=0; region<number_of_regions; region++)
800
category = power_categories[region];
802
temp = extract_l(L_mult0(region,REGION_SIZE));
803
raw_mlt_ptr = &mlt_coefs[temp];
805
temp = sub(category,(NUM_CATEGORIES-1));
809
region_mlt_bit_counts[region] =
810
vector_huffman(category, absolute_region_power_index[region],raw_mlt_ptr,
811
®ion_mlt_bits[shl_nocheck(region,2)]);
815
region_mlt_bit_counts[region] = 0;
818
total_mlt_bits = add(total_mlt_bits,region_mlt_bit_counts[region]);
822
/* If too few bits... */
823
temp = sub(total_mlt_bits,number_of_available_bits);
827
while ((temp < 0) && (*p_categorization_control > 0))
832
(*p_categorization_control)--;
833
region = category_balances[*p_categorization_control];
836
power_categories[region] = sub(power_categories[region],1);
839
total_mlt_bits = sub(total_mlt_bits,region_mlt_bit_counts[region]);
840
category = power_categories[region];
843
raw_mlt_ptr = &mlt_coefs[region*REGION_SIZE];
846
temp = sub(category,(NUM_CATEGORIES-1));
850
region_mlt_bit_counts[region] =
851
vector_huffman(category, absolute_region_power_index[region],raw_mlt_ptr,
852
®ion_mlt_bits[shl_nocheck(region,2)]);
856
region_mlt_bit_counts[region] = 0;
859
total_mlt_bits = add(total_mlt_bits,region_mlt_bit_counts[region]);
860
temp = sub(total_mlt_bits,number_of_available_bits);
863
/* If too many bits... */
864
/* Set up for while loop test */
865
temp1 = sub(total_mlt_bits,number_of_available_bits);
866
temp2 = sub(*p_categorization_control,sub(num_categorization_control_possibilities,1));
871
while ((temp1 > 0) && (temp2 < 0))
873
/* operations for while contitions */
878
region = category_balances[*p_categorization_control];
881
power_categories[region] = add(power_categories[region],1);
884
total_mlt_bits = sub(total_mlt_bits,region_mlt_bit_counts[region]);
885
category = power_categories[region];
888
temp = extract_l(L_mult0(region,REGION_SIZE));
889
raw_mlt_ptr = &mlt_coefs[temp];
892
temp = sub(category,(NUM_CATEGORIES-1));
896
region_mlt_bit_counts[region] =
897
vector_huffman(category, absolute_region_power_index[region],raw_mlt_ptr,
898
®ion_mlt_bits[shl_nocheck(region,2)]);
902
region_mlt_bit_counts[region] = 0;
905
total_mlt_bits = add(total_mlt_bits,region_mlt_bit_counts[region]);
906
(*p_categorization_control)++;
908
temp1 = sub(total_mlt_bits,number_of_available_bits);
909
temp2 = sub(*p_categorization_control,sub(num_categorization_control_possibilities,1));
913
/***************************************************************************
914
Function: vector_huffman
916
Syntax: Word16 vector_huffman(Word16 category,
921
inputs: Word16 category
925
outputs: number_of_region_bits
929
Description: Huffman encoding for each region based on category and power_index
931
WMOPS: 7kHz | 24kbit | 32kbit
932
-------|--------------|----------------
934
-------|--------------|----------------
936
-------|--------------|----------------
938
14kHz | 24kbit | 32kbit | 48kbit
939
-------|--------------|----------------|----------------
940
AVG | 0.03 | 0.03 | 0.03
941
-------|--------------|----------------|----------------
942
MAX | 0.04 | 0.04 | 0.04
943
-------|--------------|----------------|----------------
945
***************************************************************************/
946
Word16 vector_huffman(Word16 category,
953
Word16 inv_of_step_size_times_std_dev;
956
Word16 number_of_region_bits;
957
Word16 number_of_non_zero;
960
Word16 kmax, kmax_plus_one;
961
Word16 index,signs_index;
962
Word16 *bitcount_table_ptr;
963
UWord16 *code_table_ptr;
965
Word16 number_of_code_bits;
966
UWord32 current_word;
967
Word16 current_word_bits_free;
973
Word16 mytemp; /* new variable in Release 1.2 */
974
Word16 myacca; /* new variable in Release 1.2 */
977
/* initialize variables */
978
vec_dim = vector_dimension[category];
981
num_vecs = number_of_vectors[category];
984
kmax = max_bin[category];
987
kmax_plus_one = add(kmax,1);
993
current_word_bits_free = 32;
996
number_of_region_bits = 0;
999
/* set up table pointers */
1000
bitcount_table_ptr = (Word16 *)table_of_bitcount_tables[category];
1001
code_table_ptr = (UWord16 *) table_of_code_tables[category];
1003
/* compute inverse of step size * standard deviation */
1004
acca = L_mult(step_size_inverse_table[category],standard_deviation_inverse_table[power_index]);
1005
acca = L_shr_nocheck(acca,1);
1006
acca = L_add(acca,4096);
1007
acca = L_shr_nocheck(acca,13);
1010
* The next two lines are new to Release 1.2
1013
mytemp = (Word16)(acca & 0x3);
1014
acca = L_shr_nocheck(acca,2);
1016
inv_of_step_size_times_std_dev = extract_l(acca);
1019
for (n=0; n<num_vecs; n++)
1027
number_of_non_zero = 0;
1030
for (j=0; j<vec_dim; j++)
1032
k = abs_s(*raw_mlt_ptr);
1034
acca = L_mult(k,inv_of_step_size_times_std_dev);
1035
acca = L_shr_nocheck(acca,1);
1038
* The next four lines are new to Release 1.2
1041
myacca = (Word16)L_mult(k,mytemp);
1042
myacca = (Word16)L_shr_nocheck(myacca,1);
1043
myacca = (Word16)L_add(myacca,int_dead_zone_low_bits[category]);
1044
myacca = (Word16)L_shr_nocheck(myacca,2);
1046
acca = L_add(acca,int_dead_zone[category]);
1049
* The next two lines are new to Release 1.2
1052
acca = L_add(acca,myacca);
1053
acca = L_shr_nocheck(acca,13);
1055
k = extract_l(acca);
1060
number_of_non_zero = add(number_of_non_zero,1);
1061
signs_index = shl_nocheck(signs_index,1);
1064
if (*raw_mlt_ptr > 0)
1066
signs_index = add(signs_index,1);
1077
acca = L_shr_nocheck(L_mult(index,(kmax_plus_one)),1);
1078
index = extract_l(acca);
1079
index = add(index,k);
1083
code_bits = *(code_table_ptr+index);
1084
number_of_code_bits = add((*(bitcount_table_ptr+index)),number_of_non_zero);
1085
number_of_region_bits = add(number_of_region_bits,number_of_code_bits);
1087
acca = code_bits << number_of_non_zero;
1088
accb = L_deposit_l(signs_index);
1089
acca = L_add(acca,accb);
1093
/* msb of codebits is transmitted first. */
1094
j = sub(current_word_bits_free,number_of_code_bits);
1099
acca = code_bits << j;
1100
current_word = L_add(current_word,acca);
1101
current_word_bits_free = j;
1107
acca = L_shr_nocheck(code_bits,j);
1108
current_word = L_add(current_word,acca);
1110
*word_ptr++ = current_word;
1113
current_word_bits_free = sub(32,j);
1115
current_word = code_bits << current_word_bits_free;
1119
*word_ptr++ = current_word;
1122
return (number_of_region_bits);