-
Notifications
You must be signed in to change notification settings - Fork 3
/
p_parity.c
61 lines (48 loc) · 1.48 KB
/
p_parity.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
/*
ITU-T G.729A Speech Coder ANSI-C Source Code
Version 1.1 Last modified: September 1996
Copyright (c) 1996,
AT&T, France Telecom, NTT, Universite de Sherbrooke, Lucent Technologies
All rights reserved.
*/
/*------------------------------------------------------*
* Parity_pitch - compute parity bit for first 6 MSBs *
*------------------------------------------------------*/
#include "typedef.h"
#include "basic_op.h"
#include "ld8a.h"
int16_t Parity_Pitch( /* output: parity bit (XOR of 6 MSB bits) */
int16_t pitch_index /* input : index for which parity to compute */
)
{
int16_t temp, sum, i, bit;
temp = shr(pitch_index, 1);
sum = 1;
for (i = 0; i <= 5; i++) {
temp = shr(temp, 1);
bit = temp & (int16_t)1;
sum = add(sum, bit);
}
sum = sum & (int16_t)1;
return sum;
}
/*--------------------------------------------------------------------*
* check_parity_pitch - check parity of index with transmitted parity *
*--------------------------------------------------------------------*/
int16_t Check_Parity_Pitch( /* output: 0 = no error, 1= error */
int16_t pitch_index, /* input : index of parameter */
int16_t parity /* input : parity bit */
)
{
int16_t temp, sum, i, bit;
temp = shr(pitch_index, 1);
sum = 1;
for (i = 0; i <= 5; i++) {
temp = shr(temp, 1);
bit = temp & (int16_t)1;
sum = add(sum, bit);
}
sum = add(sum, parity);
sum = sum & (int16_t)1;
return sum;
}