/
melp_chn.c
1285 lines (1154 loc) · 43.6 KB
/
melp_chn.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ================================================================== */
/* */
/* Microsoft Speech coder ANSI-C Source Code */
/* SC1200 1200 bps speech coder */
/* Fixed Point Implementation Version 7.0 */
/* Copyright (C) 2000, Microsoft Corp. */
/* All rights reserved. */
/* */
/* ================================================================== */
/*
2.4 kbps MELP Proposed Federal Standard speech coder
Fixed-point C code, version 1.0
Copyright (c) 1998, Texas Instruments, Inc.
Texas Instruments has intellectual property rights on the MELP
algorithm. The Texas Instruments contact for licensing issues for
commercial and non-government use is William Gordon, Director,
Government Contracts, Texas Instruments Incorporated, Semiconductor
Group (phone 972 480 7442).
The fixed-point version of the voice codec Mixed Excitation Linear
Prediction (MELP) is based on specifications on the C-language software
simulation contained in GSM 06.06 which is protected by copyright and
is the property of the European Telecommunications Standards Institute
(ETSI). This standard is available from the ETSI publication office
tel. +33 (0)4 92 94 42 58. ETSI has granted a license to United States
Department of Defense to use the C-language software simulation contained
in GSM 06.06 for the purposes of the development of a fixed-point
version of the voice codec Mixed Excitation Linear Prediction (MELP).
Requests for authorization to make other use of the GSM 06.06 or
otherwise distribute or modify them need to be addressed to the ETSI
Secretariat fax: +33 493 65 47 16.
*/
/*
Name: melp_chn_write, melp_chn_read
Description: Write/read MELP channel bitstream
Inputs:
MELP parameter structure
Outputs:
updated MELP parameter structure (channel pointers)
Returns: void
*/
#include "sc1200.h"
#include "vq_lib.h"
#include "melp_sub.h"
#include "math_lib.h"
#include "constant.h"
#include "global.h"
#include "qnt12_cb.h"
#include "mathhalf.h"
#include "mathdp31.h"
#include "mat_lib.h"
#include "qnt12.h"
#include "msvq_cb.h"
#include "fsvq_cb.h"
#include "dsp_sub.h"
#include "fec_code.h"
#include "macro.h"
#define X0333_Q15 10923 /* (1.0/3.0) * (1 << 15) */
#define X0667_Q15 21845 /* (2.0/3.0) * (1 << 15) */
#define UV_PIND 0 /* Unvoiced pitch index */
#define INVAL_PIND 1 /* Invalid pitch index */
#define SMOOTH 16383 /* Q15 */
#define ORIGINAL_BIT_ORDER 0 /* flag to use bit order of original version */
#if (ORIGINAL_BIT_ORDER) /* Original linear order */
static const int16_t bit_order[NUM_CH_BITS] = {
0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53
};
#else /* Order based on priority of bits */
static const int16_t bit_order[NUM_CH_BITS] = {
0, 17, 9, 28, 34, 3,
4, 39, 1, 2, 13, 38,
14, 10, 11, 40, 15, 21,
27, 45, 12, 26, 25, 33,
20, 24, 23, 32, 44, 46,
22, 31, 53, 52, 51, 7,
6, 19, 18, 29, 37, 30,
36, 35, 43, 42, 16, 41,
50, 49, 48, 47, 8, 5
};
#endif
/* Define bit buffer */
static unsigned char bit_buffer[NUM_CH_BITS];
static int16_t sync_bit = 0; /* sync bit */
int16_t parity(int16_t x, int16_t leng);
void melp_chn_write(struct quant_param *qpar, unsigned char chbuf[])
{
register int16_t i;
unsigned char *bit_ptr;
int16_t bit_cntr;
/* FEC: code additional information in redundant indeces */
fec_code(qpar);
/* Fill bit buffer */
bit_ptr = bit_buffer;
bit_cntr = 0;
pack_code(qpar->gain_index[1], &bit_ptr, &bit_cntr, 5, 1);
/* Toggle and write sync bit */
sync_bit = sub(1, sync_bit);
pack_code(sync_bit, &bit_ptr, &bit_cntr, 1, 1);
pack_code(qpar->gain_index[0], &bit_ptr, &bit_cntr, 3, 1);
pack_code(qpar->pitch_index, &bit_ptr, &bit_cntr, PIT_BITS, 1);
pack_code(qpar->jit_index[0], &bit_ptr, &bit_cntr, 1, 1);
pack_code(qpar->bpvc_index[0], &bit_ptr, &bit_cntr, NUM_BANDS - 1, 1);
for (i = 0; i < MSVQ_STAGES; i++)
pack_code(qpar->msvq_index[i], &bit_ptr, &bit_cntr, msvq_bits[i], 1);
pack_code(qpar->fsvq_index, &bit_ptr, &bit_cntr, FS_BITS, 1);
/* Write channel output buffer */
qpar->chptr = chbuf;
qpar->chbit = 0;
for (i = 0; i < bitNum24; i++){
pack_code(bit_buffer[bit_order[i]], &qpar->chptr, &qpar->chbit, 1,
chwordsize);
if (i == 0) /* set beginning of frame bit */
*(qpar->chptr) |= (uint16_t) 0x8000;
}
}
BOOLEAN melp_chn_read(struct quant_param *qpar, struct melp_param *par,
struct melp_param *prev_par, unsigned char chbuf[])
{
register int16_t i;
unsigned char *bit_ptr;
BOOLEAN erase = FALSE;
int16_t index, bit_cntr, dontcare;
/* Read channel output buffer into bit buffer */
bit_ptr = bit_buffer;
qpar->chptr = chbuf;
qpar->chbit = 0;
for (i = 0; i < bitNum24; i++){
erase |= unpack_code(&(qpar->chptr), &(qpar->chbit), &index, 1,
chwordsize, ERASE_MASK);
bit_buffer[bit_order[i]] = (unsigned char) index;
bit_ptr ++;
}
/* Read information from bit buffer */
bit_ptr = bit_buffer;
bit_cntr = 0;
(void) unpack_code(&bit_ptr, &bit_cntr, &qpar->gain_index[1], 5, 1, 0);
/* Read sync bit */
(void) unpack_code(&bit_ptr, &bit_cntr, &dontcare, 1, 1, 0);
(void) unpack_code(&bit_ptr, &bit_cntr, &qpar->gain_index[0], 3, 1, 0);
(void) unpack_code(&bit_ptr, &bit_cntr, &(qpar->pitch_index), PIT_BITS,
1, 0);
(void) unpack_code(&bit_ptr, &bit_cntr, &qpar->jit_index[0], 1, 1, 0);
(void) unpack_code(&bit_ptr, &bit_cntr, &qpar->bpvc_index[0],
NUM_BANDS - 1, 1, 0);
for (i = 0; i < MSVQ_STAGES; i++)
(void) unpack_code(&bit_ptr, &bit_cntr, &(qpar->msvq_index[i]),
msvq_bits[i], 1, 0);
(void) unpack_code(&bit_ptr, &bit_cntr, &qpar->fsvq_index, FS_BITS, 1, 0);
/* Clear unvoiced flag */
qpar->uv_flag[0] = FALSE;
erase = (BOOLEAN) fec_decode(qpar, erase);
/* Decode new frame if no erasures occurred */
if (erase){ /* Erasure: frame repeat */
*par = *prev_par;
/* Force all subframes to equal last one */
fill(par->gain, par->gain[NUM_GAINFR - 1], NUM_GAINFR - 1);
} else {
/* Decode line spectrum frequencies */
vq_msd2(msvq_cb, par->lsf, msvq_cb_mean, qpar->msvq_index,
msvq_levels, MSVQ_STAGES, LPC_ORD, 2);
dontcare = FS_LEVELS;
if (qpar->uv_flag[0])
fill(par->fs_mag, ONE_Q13, NUM_HARM);
else /* Decode Fourier magnitudes */
vq_msd2(fsvq_cb, par->fs_mag, (int16_t *) NULL,
&(qpar->fsvq_index), &dontcare, 1, NUM_HARM, 0);
/* Decode gain terms with uniform log quantizer */
q_gain_dec(par->gain, qpar->gain_index, GN_QLO_Q8, GN_QUP_Q8,
GN_QLEV_M1_Q10, 5);
/* Decode voicing information */
par->uv_flag = qpar->uv_flag[0];
/* Fractional pitch: Decode logarithmic pitch period */
if (qpar->uv_flag[0])
par->pitch = UV_PITCH_Q7;
else {
quant_u_dec(qpar->pitch_index, &par->pitch, PIT_QLO_Q12,
PIT_QUP_Q12, PIT_QLEV_M1_Q8, 7);
par->pitch = pow10_fxp(par->pitch, 7);
}
/* Decode jitter */
/* quant_u_dec(par->jit_index, &par->jitter, 0.0, MAX_JITTER, 2); */
if (qpar->jit_index[0] == 0)
par->jitter = 0;
else
par->jitter = MAX_JITTER_Q15;
/* Decode bandpass voicing */
q_bpvc_dec(par->bpvc, qpar->bpvc_index[0], qpar->uv_flag[0],
NUM_BANDS);
}
/* Return erase flag */
return(erase);
}
/****************************************************************************
**
** Function: low_rate_chn_write
**
** Description: Write channel buffer for low rate ( 1200bps )
**
** Arguments:
**
** quant_param par ---- The quantization structure
**
** Return value: None
**
*****************************************************************************/
void low_rate_chn_write(struct quant_param *qpar)
{
register int16_t i;
int16_t bit_cntr, cnt;
int16_t uv1, uv2, cuv;
int16_t uv_index = 0, bp_prot1 = 0, bp_prot2 = 0, lsp_prot = 0;
int16_t uv_parity;
unsigned char *bit_ptr;
/* FEC: code additional information in redundant indices */
low_rate_fec_code(qpar);
/* ====== Fill bit buffer ====== */
bit_ptr = bit_buffer;
bit_cntr = 0;
/* ====== Toggle and write sync bit ====== */
sync_bit = sub(1, sync_bit);
pack_code(sync_bit, &bit_ptr, &bit_cntr, 1, 1);
/* ===== Count the number of voiced frame ===== */
cnt = 0;
for (i = 0; i < NF; i++){
if (!qpar->uv_flag[i])
cnt++;
}
/* ====== Packing global voicing and pitch information ====== */
if (cnt <= 1){ /* UUU UUV UVU VUU */
uv_index = 0;
bp_prot1 = 0;
if (!qpar->uv_flag[0])
bp_prot2 = 3;
else if (!qpar->uv_flag[1])
bp_prot2 = 2;
else if (!qpar->uv_flag[2])
bp_prot2 = 1;
else {
bp_prot2 = 0;
lsp_prot = 0;
}
if (bp_prot2 == 0)
qpar->pitch_index = UV_PIND;
else
qpar->pitch_index =
low_rate_pitch_enc[bp_prot2][qpar->pitch_index];
} else if (cnt == 2){ /* UVV VUV VVU */
if (qpar->uv_flag[0]){
uv_index = 4;
bp_prot1 = 3;
} else if (qpar->uv_flag[1]){
uv_index = 2;
bp_prot1 = 2;
} else if (qpar->uv_flag[2]){
uv_index = 1;
bp_prot1 = 1;
lsp_prot = 7;
}
} else if (cnt == 3){ /* VVV */
uv_index = (int16_t) (qpar->pitch_index / PITCH_VQ_SIZE);
qpar->pitch_index = sub(qpar->pitch_index,
(int16_t) (uv_index * PITCH_VQ_SIZE));
uv_index = vvv_index_map[uv_index];
}
pack_code(uv_index, &bit_ptr, &bit_cntr, UV_BITS, 1);
uv_parity = parity(uv_index, 3);
pack_code(uv_parity, &bit_ptr, &bit_cntr, 1, 1);
pack_code(qpar->pitch_index, &bit_ptr, &bit_cntr, PITCH_VQ_BITS, 1);
/* ====== Packing LSF indices ====== */
uv1 = qpar->uv_flag[0];
uv2 = qpar->uv_flag[1];
cuv = qpar->uv_flag[2];
if ((uv1 == 1) && (uv2 == 1) && (cuv == 1)){
pack_code(qpar->lsf_index[0][0], &bit_ptr, &bit_cntr, 9, 1);
pack_code(qpar->lsf_index[1][0], &bit_ptr, &bit_cntr, 9, 1);
pack_code(qpar->lsf_index[2][0], &bit_ptr, &bit_cntr, 9, 1);
pack_code(qpar->lsf_index[0][1], &bit_ptr, &bit_cntr, 4, 1);
pack_code(qpar->lsf_index[1][1], &bit_ptr, &bit_cntr, 4, 1);
pack_code(qpar->lsf_index[2][1], &bit_ptr, &bit_cntr, 4, 1);
pack_code(lsp_prot, &bit_ptr, &bit_cntr, 3, 1);
} else if ((uv1 == 1) && (uv2 == 1) && (cuv != 1)){
pack_code(qpar->lsf_index[0][0], &bit_ptr, &bit_cntr, 9, 1);
pack_code(qpar->lsf_index[1][0], &bit_ptr, &bit_cntr, 9, 1);
pack_code(qpar->lsf_index[2][0], &bit_ptr, &bit_cntr, 8, 1);
pack_code(qpar->lsf_index[2][1], &bit_ptr, &bit_cntr, 6, 1);
pack_code(qpar->lsf_index[2][2], &bit_ptr, &bit_cntr, 5, 1);
pack_code(qpar->lsf_index[2][3], &bit_ptr, &bit_cntr, 5, 1);
} else if ((uv1 == 1) && (uv2 != 1) && (cuv == 1)){
pack_code(qpar->lsf_index[0][0], &bit_ptr, &bit_cntr, 9, 1);
pack_code(qpar->lsf_index[1][0], &bit_ptr, &bit_cntr, 8, 1);
pack_code(qpar->lsf_index[1][1], &bit_ptr, &bit_cntr, 6, 1);
pack_code(qpar->lsf_index[1][2], &bit_ptr, &bit_cntr, 5, 1);
pack_code(qpar->lsf_index[1][3], &bit_ptr, &bit_cntr, 5, 1);
pack_code(qpar->lsf_index[2][0], &bit_ptr, &bit_cntr, 9, 1);
} else if ((uv1 != 1) && (uv2 == 1) && (cuv == 1)){
pack_code(qpar->lsf_index[0][0], &bit_ptr, &bit_cntr, 8, 1);
pack_code(qpar->lsf_index[0][1], &bit_ptr, &bit_cntr, 6, 1);
pack_code(qpar->lsf_index[0][2], &bit_ptr, &bit_cntr, 5, 1);
pack_code(qpar->lsf_index[0][3], &bit_ptr, &bit_cntr, 5, 1);
pack_code(qpar->lsf_index[1][0], &bit_ptr, &bit_cntr, 9, 1);
pack_code(qpar->lsf_index[2][0], &bit_ptr, &bit_cntr, 9, 1);
} else {
if ((uv1 != 1) && (uv2 != 1) && (cuv == 1)){
/* ---- Interpolation [4 inp + (8+6+6+6) res + 9 uv] ---- */
pack_code(qpar->lsf_index[0][0], &bit_ptr, &bit_cntr, 9, 1);
} else {
pack_code(qpar->lsf_index[0][0], &bit_ptr, &bit_cntr, 8, 1);
pack_code(qpar->lsf_index[0][1], &bit_ptr, &bit_cntr, 6, 1);
pack_code(qpar->lsf_index[0][2], &bit_ptr, &bit_cntr, 5, 1);
pack_code(qpar->lsf_index[0][3], &bit_ptr, &bit_cntr, 5, 1);
}
pack_code(qpar->lsf_index[1][0], &bit_ptr, &bit_cntr, 4, 1);
if ((uv1 != 1) && (uv2 != 1) && (cuv == 1)){
pack_code(qpar->lsf_index[2][0], &bit_ptr, &bit_cntr, 8, 1);
pack_code(qpar->lsf_index[2][1], &bit_ptr, &bit_cntr, 6, 1);
pack_code(qpar->lsf_index[2][2], &bit_ptr, &bit_cntr, 6, 1);
pack_code(qpar->lsf_index[2][3], &bit_ptr, &bit_cntr, 6, 1);
pack_code(lsp_prot, &bit_ptr, &bit_cntr, 3, 1);
} else {
pack_code(qpar->lsf_index[2][0], &bit_ptr, &bit_cntr, 8, 1);
pack_code(qpar->lsf_index[2][1], &bit_ptr, &bit_cntr, 6, 1);
}
}
/* ====== Packing gain index ====== */
pack_code(qpar->gain_index[0], &bit_ptr, &bit_cntr, GAIN_VQ_BITS, 1);
/* ====== Packing voicing indices ====== */
for (i = 0; i < NF; i++){
if (!qpar->uv_flag[i])
pack_code(qpar->bpvc_index[i], &bit_ptr, &bit_cntr, 2, 1);
}
if (cnt == 2)
pack_code(bp_prot1, &bit_ptr, &bit_cntr, 2, 1);
else if (cnt == 1){
pack_code(bp_prot2, &bit_ptr, &bit_cntr, 2, 1);
pack_code(bp_prot1, &bit_ptr, &bit_cntr, 2, 1);
} else if (cnt == 0){ /* UUU */
pack_code(qpar->bpvc_index[0], &bit_ptr, &bit_cntr, 2, 1);
pack_code(bp_prot2, &bit_ptr, &bit_cntr, 2, 1);
pack_code(bp_prot1, &bit_ptr, &bit_cntr, 2, 1);
}
/* ====== Packing Fourier magnitudes ====== */
pack_code(qpar->fs_index, &bit_ptr, &bit_cntr, FS_BITS, 1);
/* ====== Packing jitter index ====== */
pack_code(qpar->jit_index[0], &bit_ptr, &bit_cntr, 1, 1);
/* ======== Write channel output buffer ======== */
qpar->chptr = chbuf;
qpar->chbit = 0;
for (i = 0; i < bitNum12; i++){
pack_code(bit_buffer[i], &qpar->chptr, &qpar->chbit, 1, chwordsize);
if (i == 0)
*(qpar->chptr) |= 0x8000; /* set beginning of frame bit */
}
}
/****************************************************************************
**
** Function: low_rate_chn_read
**
** Description: Unpacking the channel buffer for low rate ( 1200bps )
**
** Arguments:
**
** quant_param par ---- The quantization structure
**
** Return value: None
**
*****************************************************************************/
BOOLEAN low_rate_chn_read(struct quant_param *qpar, struct melp_param *par,
struct melp_param *prev_par)
{
int16_t i, j, k;
static int16_t prev_uv = 1;
static int16_t prev_fsmag[NUM_HARM];
static int16_t qplsp[LPC_ORD], prev_gain[2*NF*NUM_GAINFR];
static int16_t firstTime = TRUE;
const int16_t *codebook;
int16_t erase = 0, lsp_check[NF] = {0,0,0};
int16_t bit_cntr, bit_cntr1, cnt, last, index, dontcare;
int16_t prot_bp1, prot_bp2, prot_lsp;
int16_t uv1, uv2, cuv, uv_index, uv_parity;
unsigned char *bit_ptr, *bit_ptr1;
int16_t ilsp1[LPC_ORD], ilsp2[LPC_ORD], res[2*LPC_ORD];
int16_t temp1, temp2, p_value, q_value;
int16_t intfact;
int16_t weighted_fsmag[NUM_HARM]; /* Q13 */
int16_t erase_uuu = 0, erase_vvv = 0;
int16_t flag_parity = 0, flag_dec_lsp = 1, flag_dec_pitch = 1;
int16_t melp_v_cb_size[4] = {256, 64, 32, 32};
int16_t res_cb_size[4] = {256, 64, 64, 64};
int16_t melp_uv_cb_size[1] = {512};
int32_t L_acc, L_sum1, L_sum2;
/* In previous versions we use unweighted_fsmag[] and prev_fsmag[] to */
/* keep track of a previous par[].fs_mag array. They were obtained by */
/* multiplying the w_fs_inv[] arrays with par[].fs_mag, and they are */
/* weighted by w_fs[] when they are used later. In floating point */
/* version this is straightforward but in fixed point the multiplication */
/* of w_fs_inv[] and w_fs[] do not yield the original data. Modifica- */
/* tions are made to remove this to and fro inversions. */
if (firstTime){ /* Initialization */
temp2 = shl(LPC_ORD, 10); /* Q10 */
temp1 = X08_Q10; /* Q10 */
for (i = 0; i < LPC_ORD; i++){
/* qplsp[i] = (i + 1)*0.8/LPC_ORD; */
qplsp[i] = divide_s(temp1, temp2);
temp1 = add(temp1, X08_Q10);
}
fill(prev_gain, 2560, 2*NF*NUM_GAINFR);
fill(prev_fsmag, ONE_Q13, NUM_HARM);
firstTime = FALSE;
}
/* ======== Read channel output buffer into bit buffer ======== */
bit_ptr = bit_buffer;
qpar->chptr = chbuf;
qpar->chbit = 0;
for (i = 0; i < bitNum12; i++){
erase |= unpack_code(&qpar->chptr, &qpar->chbit, &index, 1,
chwordsize, ERASE_MASK);
bit_buffer[i] = (unsigned char) index;
bit_ptr++;
}
bit_ptr = bit_buffer;
bit_cntr = 0;
/* ====== Read sync bit ====== */
unpack_code(&bit_ptr, &bit_cntr, &dontcare, 1, 1, 0);
/* ====== Unpacking Global U/V dicision ====== */
unpack_code(&bit_ptr, &bit_cntr, &uv_index, UV_BITS, 1, 0);
/* ====== Unpacking parity bit ====== */
unpack_code(&bit_ptr, &bit_cntr, &uv_parity, 1, 1, 0);
/* ====== Unpacking pitch information ====== */
unpack_code(&bit_ptr, &bit_cntr, &qpar->pitch_index, PITCH_VQ_BITS, 1, 0);
/* error check in U/V pattern */
bit_ptr1 = bit_ptr;
bit_cntr1= bit_cntr;
/* unpack_code(&bit_ptr1, &bit_cntr1, &dontcare, 39, 1, 0); LSP */
bit_cntr1 = 0; bit_ptr1 += 39;
unpack_code(&bit_ptr1, &bit_cntr1, &prot_lsp, 3, 1, 0); /* LSP */
unpack_code(&bit_ptr1, &bit_cntr1, &dontcare, 10, 1, 0); /* GAIN */
unpack_code(&bit_ptr1, &bit_cntr1, &dontcare, 2, 1, 0); /* BP */
unpack_code(&bit_ptr1, &bit_cntr1, &prot_bp2, 2, 1, 0); /* BP */
unpack_code(&bit_ptr1, &bit_cntr1, &prot_bp1, 2, 1, 0); /* BP */
if (uv_parity != parity(uv_index, 3))
flag_parity |= 1;
/* Mode checking */
if (uv_index == 0){
if (!flag_parity){
j = qpar->pitch_index;
qpar->pitch_index = low_rate_pitch_dec[qpar->pitch_index];
if (qpar->pitch_index == UV_PIND){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 0){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (qpar->pitch_index == INVAL_PIND){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
} else {
qpar->pitch_index -= 2;
for (i = k = 0; i < PITCH_VQ_BITS; i++){
if ((j & 0x1) == 1) k++;
j >>= 1;
}
if (k == 6 || k == 7){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 0;
if (prot_bp2 != 1){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (k == 4){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 2){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (k == 5){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 3){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
}
}
} else if (prot_bp1 == 0){
j = qpar->pitch_index;
qpar->pitch_index = low_rate_pitch_dec[qpar->pitch_index];
if (qpar->pitch_index == UV_PIND){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 0){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (qpar->pitch_index == INVAL_PIND){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
} else {
qpar->pitch_index -= 2;
for (i = k = 0; i < PITCH_VQ_BITS; i++){
if ((j & 0x1) == 1) k++;
j >>= 1;
}
if (k == 6 || k == 7){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 0;
if (prot_bp2 != 1){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (k == 4){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 2){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (k == 5){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 3){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
}
}
} else {
if (prot_bp2 == 1 && prot_lsp == 7){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 1;
} else if (prot_bp2 == 2){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 0;
} else if (prot_bp2 == 3){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 0;
} else {
erase_vvv |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 2;
}
}
} else if (uv_index == 1 || uv_index == 2 || uv_index == 4){
if (!flag_parity){
if (uv_index == 1){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 1;
} else if (uv_index == 2){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 0;
} else if (uv_index == 4){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 0;
}
} else {
if (prot_bp1 == 0){
j = qpar->pitch_index;
qpar->pitch_index = low_rate_pitch_dec[qpar->pitch_index];
if (qpar->pitch_index == UV_PIND){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_lsp != 0){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (qpar->pitch_index == INVAL_PIND){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
} else {
qpar->pitch_index -= 2;
for (i = k = 0; i < PITCH_VQ_BITS; i++){
if ((j & 0x1) == 1) k++;
j >>= 1;
}
if (k == 6 || k == 7){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 0;
if (prot_bp2 != 1){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (k == 4){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 2){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
} else if (k == 5){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 1;
if (prot_bp2 != 3){
erase_uuu |= 1;
flag_dec_lsp = 0;
flag_dec_pitch = 0;
}
}
}
} else if (prot_bp1 == 1 && prot_lsp == 7){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 1;
} else {
erase_vvv |= 1;
}
}
} else if (uv_index == 3 || uv_index == 5){
if (!flag_parity){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 0;
if (uv_index == 3)
qpar->pitch_index = qpar->pitch_index;
else if (uv_index == 5)
qpar->pitch_index = (int16_t) (qpar->pitch_index + PITCH_VQ_SIZE);
} else {
if (prot_bp1 == 1 && prot_lsp == 7){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 1;
} else {
erase_vvv |= 1;
if (uv_index == 3)
qpar->pitch_index = qpar->pitch_index;
else if (uv_index == 5)
qpar->pitch_index = (int16_t) (qpar->pitch_index + PITCH_VQ_SIZE);
}
}
} else if (uv_index == 6){
if (!flag_parity){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 0;
qpar->pitch_index = (int16_t) (qpar->pitch_index + 2*PITCH_VQ_SIZE);
} else {
if (prot_bp1 == 2){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 0;
}
if (prot_bp1 == 3){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 0;
} else {
erase_vvv |= 1;
qpar->pitch_index = (int16_t) (qpar->pitch_index + 2*PITCH_VQ_SIZE);
}
}
} else if (uv_index == 7){
if (!flag_parity){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 0;
qpar->pitch_index = (int16_t) (qpar->pitch_index + 3*PITCH_VQ_SIZE);
} else {
erase_vvv |= 1;
qpar->pitch_index = (int16_t) (qpar->pitch_index + 3*PITCH_VQ_SIZE);
}
}
if (erase_uuu){
qpar->uv_flag[0] = par[0].uv_flag = 1;
qpar->uv_flag[1] = par[1].uv_flag = 1;
qpar->uv_flag[2] = par[2].uv_flag = 1;
}
if (erase_vvv){
qpar->uv_flag[0] = par[0].uv_flag = 0;
qpar->uv_flag[1] = par[1].uv_flag = 0;
qpar->uv_flag[2] = par[2].uv_flag = 0;
}
/* ====== Unpacking LSF information ====== */
last = -1;
cnt = 0;
for (i = 0; i < NF; i++){
if (!qpar->uv_flag[i]){
cnt++;
last = i;
}
}
uv1 = qpar->uv_flag[0];
uv2 = qpar->uv_flag[1];
cuv = qpar->uv_flag[2];
if ((uv1 == 1) && (uv2 == 1) && (cuv == 1)){
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][0]), 9, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][0]), 9, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][0]), 9, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][1]), 4, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][1]), 4, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][1]), 4, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &dontcare, 3, 1, 0);
} else if ((uv1 == 1) && (uv2 == 1) && (cuv != 1)){
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][0]), 9, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][0]), 9, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][0]), 8, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][1]), 6, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][2]), 5, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][3]), 5, 1, 0);
} else if ((uv1 == 1) && (uv2 != 1) && (cuv == 1)){
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][0]), 9, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][0]), 8, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][1]), 6, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][2]), 5, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][3]), 5, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][0]), 9, 1, 0);
} else if ((uv1 != 1) && (uv2 == 1) && (cuv == 1)){
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][0]), 8, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][1]), 6, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][2]), 5, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][3]), 5, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][0]), 9, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][0]), 9, 1, 0);
} else {
if ((uv1 != 1) && (uv2 != 1) && (cuv == 1)){
/* ---- Interpolation [4 inp + (8+6+6+6) res + 9 uv] ---- */
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][0]),
9, 1, 0);
} else {
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][0]),
8, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][1]),
6, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][2]),
5, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[0][3]),
5, 1, 0);
}
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[1][0]), 4, 1, 0);
if ((uv1 != 1) && (uv2 != 1) && (cuv == 1)){
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][0]),
8, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][1]),
6, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][2]),
6, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][3]),
6, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &dontcare, 3, 1, 0);
} else {
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][0]),
8, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &(qpar->lsf_index[2][1]),
6, 1, 0);
}
}
/* ====== Unpacking gain information ====== */
unpack_code(&bit_ptr, &bit_cntr, &(qpar->gain_index[0]),
GAIN_VQ_BITS, 1, 0);
/* ====== Unpacking voicing information ====== */
for (i = 0; i < NF; i++){
if (!qpar->uv_flag[i])
unpack_code(&bit_ptr, &bit_cntr, &(qpar->bpvc_index[i]), 2, 1, 0);
}
if (cnt == 2)
unpack_code(&bit_ptr, &bit_cntr, &prot_bp1, 2, 1, 0);
else if (cnt == 1){
unpack_code(&bit_ptr, &bit_cntr, &prot_bp2, 2, 1, 0);
unpack_code(&bit_ptr, &bit_cntr, &prot_bp1, 2, 1, 0);
} else if (cnt == 0){ /* UUU */
for (i = 0; i < NF; i++)
unpack_code(&bit_ptr, &bit_cntr, &(qpar->bpvc_index[i]), 2, 1, 0);
}
/* ====== Unpacking Fourier magnitudes information ====== */
unpack_code(&bit_ptr, &bit_cntr, &(qpar->fs_index), FS_BITS, 1, 0);
/* ====== Unpacking jitter information ====== */
unpack_code(&bit_ptr, &bit_cntr, &(qpar->jit_index[0]), 1, 1, 0);
/* ====== FEC decoding ====== */
erase = low_rate_fec_decode(qpar, erase, lsp_check);
/* ====== Decode pitch information ====== */
if (flag_dec_pitch == 1){
if (cnt == 0){
for (i = 0; i < NF; i++)
par[i].pitch = LOG_UV_PITCH_Q12;
} else if (cnt == 1){
for (i = 0; i < NF; i++){
if (!par[i].uv_flag)
quant_u_dec(qpar->pitch_index, &par[i].pitch,
PIT_QLO_Q12, PIT_QUP_Q12, PIT_QLEV_M1_Q8, 7);
else
par[i].pitch = LOG_UV_PITCH_Q12;
par[i].pitch = pow10_fxp(par[i].pitch, 7);
}
} else if (cnt > 1){
index = qpar->pitch_index;
/* ----- set pointer -----*/
if( cnt == NF )
codebook = pitch_vq_cb_vvv;
else
codebook = pitch_vq_cb_uvv;
for (i = 0; i < NF; i++){
if (par[i].uv_flag == 1)
par[i].pitch = UV_PITCH_Q7;
else
par[i].pitch = pow10_fxp(codebook[index*NF + i], 7);
}
}
} else if (flag_dec_pitch == 2){
codebook = pitch_vq_cb_uvv; /* = pitch_vq_cb_uvu = pitch_vq_cb_vvu */
index = qpar->pitch_index;
for (i = 0; i < NF; i++)
par[i].pitch = pow10_fxp(codebook[index*NF + i], 7);
}
/* ====== Decode LSF information ====== */
if (flag_dec_lsp){
if ((uv1 == 1) && (uv2 == 1) && (cuv == 1)){
deqnt_msvq(&(par[0].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[0], LPC_ORD);
deqnt_msvq(&(par[1].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[1], LPC_ORD);
deqnt_msvq(&(par[2].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[2], LPC_ORD);
} else if ((uv1 == 1) && (uv2 == 1) && (cuv != 1)){
deqnt_msvq(&(par[0].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[0], LPC_ORD);
deqnt_msvq(&(par[1].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[1], LPC_ORD);
deqnt_msvq(&(par[2].lsf[0]), lsp_v_256x64x32x32, 4, melp_v_cb_size,
qpar->lsf_index[2], LPC_ORD);
} else if ((uv1 == 1) && (uv2 != 1) && (cuv == 1)){
deqnt_msvq(&(par[0].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[0], LPC_ORD);
deqnt_msvq(&(par[1].lsf[0]), lsp_v_256x64x32x32, 4, melp_v_cb_size,
qpar->lsf_index[1], LPC_ORD);
deqnt_msvq(&(par[2].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[2], LPC_ORD);
} else if ((uv1 != 1) && (uv2 == 1) && (cuv == 1)){
deqnt_msvq(&(par[0].lsf[0]), lsp_v_256x64x32x32, 4, melp_v_cb_size,
qpar->lsf_index[0], LPC_ORD);
deqnt_msvq(&(par[1].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[1], LPC_ORD);
deqnt_msvq(&(par[2].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[2], LPC_ORD);
} else {
if ((uv1 != 1) && (uv2 != 1) && (cuv == 1))
/* ---- Interpolation [4 inp + (8+6+6+6) res + 9 uv] ---- */
deqnt_msvq(&(par[2].lsf[0]), lsp_uv_9, 1, melp_uv_cb_size,
qpar->lsf_index[0], LPC_ORD);
else
deqnt_msvq(&(par[2].lsf[0]), lsp_v_256x64x32x32, 4,
melp_v_cb_size, qpar->lsf_index[0], LPC_ORD);
i = qpar->lsf_index[1][0];
for (j = 0; j < LPC_ORD; j++){
/* ilsp1[j] = inpCoef[i][j] * qplsp[j] +
(1.0 - inpCoef[i][j]) * par[2].lsf[j]; */
intfact = inpCoef[i][j]; /* Q14 */
L_acc = L_mult(intfact, qplsp[j]); /* Q14 */
intfact = sub(ONE_Q14, intfact);
L_acc = L_mac(L_acc, intfact, par[2].lsf[j]);
ilsp1[j] = extract_h(L_shl(L_acc, 1)); /* Q15 */
/* ilsp2[j] = inpCoef[i][j+10] * qplsp[j] +
(1.0 - inpCoef[i][j + LPC_ORD]) * par[2].lsf[j]; */
intfact = inpCoef[i][j + LPC_ORD]; /* Q14 */
L_acc = L_mult(intfact, qplsp[j]); /* Q14 */
intfact = sub(ONE_Q14, intfact);
L_acc = L_mac(L_acc, intfact, par[2].lsf[j]);
ilsp2[j] = extract_h(L_shl(L_acc, 1)); /* Q15 */
}