This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathp_parity.c
62 lines (52 loc) · 1.71 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
62
/*
ITU-T G.729A Speech Coder with Annex B ANSI-C Source Code
*/
/*
----------------------------------------------------------------------
COPYRIGHT NOTICE
----------------------------------------------------------------------
ITU-T G.729 Annex C ANSI C source code
Copyright (C) 1998, AT&T, France Telecom, NTT, University of
Sherbrooke. All rights reserved.
----------------------------------------------------------------------
*/
#include "typedef.h"
#include "ld8a.h"
/*-----------------------------------------------------*
* parity_pitch - compute parity bit for first 6 MSBs *
*-----------------------------------------------------*/
int parity_pitch( /* output: parity bit (XOR of 6 MSB bits) */
int pitch_index /* input : index for which parity is computed */
)
{
int temp, sum, i, bit;
temp = pitch_index >> 1;
sum = 1;
for (i = 0; i <= 5; i++) {
temp >>= 1;
bit = temp & 1;
sum = sum + bit;
}
sum = sum & 1;
return (sum);
}
/*--------------------------------------------------------------------*
* check_parity_pitch - check parity of index with transmitted parity *
*--------------------------------------------------------------------*/
int check_parity_pitch( /* output: 0 = no error, 1= error */
int pitch_index, /* input : index of parameter */
int parity /* input : parity bit */
)
{
int temp, sum, i, bit;
temp = pitch_index >> 1;
sum = 1;
for (i = 0; i <= 5; i++) {
temp >>= 1;
bit = temp & 1;
sum = sum + bit;
}
sum += parity;
sum = sum & 1;
return (sum);
}