Skip to content

Commit

Permalink
Added G722 info
Browse files Browse the repository at this point in the history
  • Loading branch information
njh committed Jan 24, 2006
1 parent a5a2abb commit 7804f02
Show file tree
Hide file tree
Showing 16 changed files with 3,348 additions and 0 deletions.
709 changes: 709 additions & 0 deletions g722/adpcm64_g722/decoder.c

Large diffs are not rendered by default.

549 changes: 549 additions & 0 deletions g722/adpcm64_g722/encoder.c

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions g722/adpcm64_g722/mk_bin.c
@@ -0,0 +1,13 @@
#include <stdio.h>
main()
{
int i;
char sc[2], t;
short s;

while (fscanf(stdin, "%d", &i) == 1) {
s = i;
fwrite(&s, sizeof(short), 1, stdout);
}
exit(0);
}
56 changes: 56 additions & 0 deletions g722/adpcm64_g722/rcv_qmf.c
@@ -0,0 +1,56 @@
/******************************* RECIEVE QMF ************************/

#include <stdio.h>
main ()
{
int i; /* counter */
int rl, rh; /* low and high band pcm input */
int xout1, xout2; /* even and odd tap accumulators */
FILE *infile; /* input file pointer */
FILE *outfile; /* output file pointer */
static int h[24] = /* qmf tap coefficients */
{3, -11, -11, 53, 12, -156,
32, 362, -210, -805, 951, 3876,
3876, 951, -805, -210, 362, 32,
-156, 12, 53, -11, -11, 3} ;
static int xd[12] =
{0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0} ;
static int xs[12] =
{0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0} ;

infile = fopen("testout.dat", "r");
outfile = fopen("pcmout.dat", "w+");
nextpcm:
fscanf(infile, "%d%d", &rl, &rh) ;
if (rl == 32767) goto finish;
for (i=11; i>0; i--) { xd[i] = xd[i-1]; xs[i] = xs[i-1]; }
/************************************* RECA ***************************/
xd[0] = rl - rh ;
if (xd[0] > 16383) xd[0] = 16383;
if (xd[0] < -16384) xd[0] = -16384;
/************************************* RECB ***************************/
xs[0] = rl + rh ;
if (xs[0] > 16383) xs[0] = 16383;
if (xs[0] < -16384) xs[0] = -16384;
/************************************* ACCUMC *************************/
xout1 = 0;
for (i=0; i<12; i+=1) xout1 += xd[i] * h[2*i];
xout1 = xout1 >> 12 ;
if (xout1 > 16383) xout1 = 16383 ;
if (xout1 < -16384) xout1 = -16384 ;
/************************************* ACCUMD *************************/
xout2 = 0;
for (i=0; i<12; i+=1) xout2 += xs[i] * h[2*i+1];
xout2 = xout2 >> 12 ;
if (xout2 > 16383) xout2 = 16383 ;
if (xout2 < -16384) xout2 = -16384 ;
/************************************* SELECT *************************/
fprintf (outfile, "%5d\n%5d\n", xout1, xout2 ) ;
goto nextpcm;

finish:
fprintf (outfile, "32767 32767 \n");

}
15 changes: 15 additions & 0 deletions g722/adpcm64_g722/swab.c
@@ -0,0 +1,15 @@
#include <stdio.h>
main()
{
int i;
char sc[2], t;
short s;

while (fscanf(stdin, "%d", &i) == 1) {
s = i;
bcopy(&s, sc, sizeof(short));
t = sc[0]; sc[0] = sc[1]; sc[1] = t;
bcopy(sc, &s, sizeof(short));
fprintf(stdout, "%d\n", s);
}
}
77 changes: 77 additions & 0 deletions g722/adpcm64_g722/trn_qmf.c
@@ -0,0 +1,77 @@
#include <stdio.h>
main ()
{

/* This program performs the transmit qmf function for the 64 kb/s */
/* codec. It reads 14 bit decimial PCM values from standard input */
/* and writes 14 bit high and low band PCM values to standard */
/* output, two to the line. The input must be terminated by the */
/* PCM value of 32767, and the last output line contains 32767 */
/* and 32767 as a terminator for that file. */

int i; /* counter */
int pcm; /* pcm input from stdin */
int pcmlow, pcmhigh; /* low and high band pcm from qmf*/
int sumeven, sumodd; /* even and odd tap accumulators */
int decimate = 1; /* switch used to decimate qmf */
FILE *infile; /* input file pointer */
FILE *outfile; /* output file pointer */
/* output every other time */

static int h[24] = /* qmf tap coefficients */
{3, -11, -11, 53, 12, -156,
32, 362, -210, -805, 951, 3876,
3876, 951, -805, -210, 362, 32,
-156, 12, 53, -11, -11, 3} ;
static int x[24] = /* storage for signal passing */
/* through the qmf */
{0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0};

/* BEGINNING OF EXECUTION, READ IN A PCM SAMPLE FROM STDIN */

infile = fopen("pcmin.dat", "r");
outfile = fopen("testin.dat", "w+");
nextpcm:
fscanf(infile, "%d", &pcm);
if (pcm == 32767) goto finish;

/* PROCESS PCM THROUGH THE QMF FILTER */

for (i=23; i>0; i--) x[i] = x[i-1];
x[0] = pcm;

/* DISCARD EVERY OTHER QMF OUTPUT */

decimate = - decimate;
if ( decimate < 0 ) goto nextpcm;

sumodd = 0;
for (i=1; i<24; i+=2) sumodd += x[i] * h[i];

sumeven = 0;
for (i=0; i<24; i+=2) sumeven += x[i] * h[i];

pcmlow = (sumeven + sumodd) >> 13 ;
pcmhigh = (sumeven - sumodd) >> 13 ;

if (pcmlow > 16383) pcmlow = 16383 ;
if (pcmlow < -16384) pcmlow = -16384 ;
if (pcmhigh > 16383) pcmhigh = 16383 ;
if (pcmhigh < -16383) pcmhigh = -16383 ;


writeadp:
fprintf (outfile, "%d %d \n", pcmlow, pcmhigh);
goto nextpcm;

/* FINISH UP BY WRITING 32767 AT THE END OF THE FILE */

finish:
fprintf (outfile, "32767 32767 \n");

}


23 changes: 23 additions & 0 deletions g722/adpcm64_g722_efficient/README
@@ -0,0 +1,23 @@
This directory contains the source code for the
CCITT G.722 standard speech compression/decompression
algorithm. The code was originally written by Milton Anderson
(milton@thumper.bellcore.com) from BELLCORE, and has
been modified by Chengxiang Lu and Alex Hauptmann from the Speech Group,
Computer Science Department, Carnegie Mellon University to be fairly fast
and efficient, while retaining high fidelity.

decoder.c contains all the code to decompress an encoded file.
Usage: adpcm_decoder < adpcm_file > pcm_file

encoder.c contains all the code to compress a raw speech file
Usage: adpcm_coder < pcm_file > adpcm_file

sample test files are provided:

pcminb.dat (raw speech data, PCM, 16khz, 16 bit (signed)).

Read the file adpcm.tex or adpcm.ps for more information.

If you have questions, please contact Alex Hauptmann (alex@cs.cmu.edu)
or Chengxiang Lu (lu+@cs.cmu.edu).

9 changes: 9 additions & 0 deletions g722/adpcm64_g722_efficient/adpcm.aux
@@ -0,0 +1,9 @@
\relax
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {1}Encoding:}{1}}
\citation{Papamichalis87,JayantandNoll84,IwadareandNishitani88}
\bibstyle{plain}
\bibdata{adpcm}
\bibcite{IwadareandNishitani88}{1}
\bibcite{JayantandNoll84}{2}
\bibcite{Papamichalis87}{3}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {2}Decoding:}{2}}
20 changes: 20 additions & 0 deletions g722/adpcm64_g722_efficient/adpcm.bbl
@@ -0,0 +1,20 @@
\begin{thebibliography}{1}

\bibitem{IwadareandNishitani88}
M.~Iwadare and T~Nishitani.
\newblock 64 kbit/s audio signal transmission approaches using 32 kbit/s adpcm
channel banks.
\newblock {\em IEEE Journal on selected areas in communication}, 6(2):307 --
313, February 1988.

\bibitem{JayantandNoll84}
N.S. Jayant and P.~Noll.
\newblock {\em Digital Coding of Waveforms}.
\newblock Prentice Hall, Englewood Cliffs, NJ, 1984.

\bibitem{Papamichalis87}
P.E. Papamichalis.
\newblock {\em Practical Approaches to Speech Coding}.
\newblock Prentice-Hall, Englewood Cliffs, NJ, 1987.

\end{thebibliography}
29 changes: 29 additions & 0 deletions g722/adpcm64_g722_efficient/adpcm.bib
@@ -0,0 +1,29 @@
@book(Papamichalis87,
author = "Papamichalis, P.E.",
key = "Papamichalis",
title = "Practical Approaches to Speech Coding",
publisher = "Prentice-Hall",
address = "Englewood Cliffs, NJ",
year = 1987,
annote = "describes adpcm speech coding, decoding, encoding and
others. section3")

@book(JayantandNoll84,
author = "Jayant, N.S. and Noll, P.",
title = "Digital Coding of Waveforms",
publisher = "Prentice Hall",
address = "Englewood Cliffs, NJ",
year = 1984,
annote = "adpcm encoding and decoding")

@article(IwadareandNishitani88,
author = "Iwadare, M. and Nishitani, T",
title = "64 kbit/s Audio Signal Transmission Approaches
Using 32 kbit/s ADPCM Channel Banks",
journal = "IEEE Journal on selected areas in communication",
volume = 6,
number = 2,
month = "February",
year = 1988,
pages = "307 - 313",
annote = "adpcm encoding and decoding")
4 changes: 4 additions & 0 deletions g722/adpcm64_g722_efficient/adpcm.blg
@@ -0,0 +1,4 @@
This is BibTeX, C Version 0.99c
The top-level auxiliary file: adpcm.aux
The style file: plain.bst
Database file #1: adpcm.bib
Binary file added g722/adpcm64_g722_efficient/adpcm.ps
Binary file not shown.
91 changes: 91 additions & 0 deletions g722/adpcm64_g722_efficient/adpcm.tex
@@ -0,0 +1,91 @@
\documentstyle[times]{article}
\setlength{\parskip}{2ex}\setlength{\parindent}{0pt}
\renewcommand{\topfraction}{0.95}
\renewcommand{\textfraction}{0.05}
\setcounter{topnumber}{2}\setcounter{bottomnumber}{2}

\title{A fast program for Adaptive Differential Pulse Code Modulation}
\author{Chengxiang Lu and Alexander G. Hauptmann}

% Speech Group, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA, USA
\begin{document}
\maketitle

% {\center{\bf ABSTRACT}\\}

Sound signals must be coded efficiently for many applications.
One of these coding techniques is the 64 kbit/s audio coding system
which has been made a standard by the CCITT G.722.
The technique takes a 16 kHz (14 bit or 16 bit) input signal with a bandwidth
7kHz and encodes it to 64 kbits/s.
The code was originally written by Milton Anderson (milton@thumper.bellcore.com)
from BELLCORE, and has
been modified by the authors at the Speech Group, School of Computer Science,
Carnegie Mellon University, to be fairly fast and efficient,
while retaining high fidelity.

This program performs the 64kbit/s CCITT ADPCM CODEC fairly efficiently.
The program is written in ANSI "C" and has been optimized to run efficiently
on many smaller workstations. We tested the program on a NeXT
workstation using a Motorola 68040 processor at 25 MHz and found it
to run in about .6 times real time.
The program is available by ftp from CMU, and may be used and distributed
freely, provided the copyright notices are maintained.

The Carnegie Mellon ADPCM program is Copyright (c) 1993
by Carnegie Mellon University. Use of this program, for any research or
commercial purpose, is completely unrestricted. If you make use of or
redistribute this material, we would appreciate acknowlegement of its origin.

Feel free to
contact the authors by e-mail (lu+@cs.cmu.edu or alex@cs.cmu.edu)
for more information.
We would appreciate if you sent us any changes or improvements to the code
so we can further distribute them. If you register your name with us,
notice of all future updates will be automatically forwarded to you.

\section{Encoding:}

Encoding is done in the following steps:

\begin{enumerate}
\item Read 16kHz sampled 14 bit PCM values.

\item Split the total frequency band of input signals into two
subbands -- (a Low-band and a High-band) by using QMF
(quadrature mirror filters).

\item Each band signal is encoded by ADPCM which
assigns 2 bits and 6 bits to each pair of high- and low-band signals,
respectively.
\end{enumerate}

\section{Decoding:}

[add decoder picture]

Decoding is done in the following steps:
\begin{enumerate}
\item Read encoded signals.

\item Each signal is decoded by ADPCM.

\item The decoded signals are subjected to a doubling of the sampling
frequency achieved by inserting zero samples.

\item The two 16kHz sampled signals are fed into the receiver QMF and
added together.

\end{enumerate}

For details about the basic procedure, refer to
\cite{Papamichalis87,JayantandNoll84,IwadareandNishitani88}.

In the near future, we plan to test the ADPCM encoding with our recognition
system and report on accuracy decreases.


\bibliographystyle{plain}
\bibliography{adpcm}

\end{document}

0 comments on commit 7804f02

Please sign in to comment.