PCM Examples - Tutorial
PCM Examples - Tutorial
Rechnernetze
http://www.rasip.fer.hr/research/compress/algorithms/fund/pcm/index.html
What is PCM?
PCM is a method of converting an analog into digital signals. Information in an analog
form cannot be processed by digital computers so it's necessary to convert them into
digital form. PCM is a term which was formed during the development of digital audio
transmission standards. Digital data can be transported robustly over long distances
unlike the analog data and can be interleaved with other digital data so various
combinations of transmission channels can be used. In the text which follows this
term will apply to encoding technique which means digitalization of analog information
in general.
PCM doesn`t mean any specific kind of compression, it only implies PAM (pulse
amplitude modulation) - quantization by amplitude and quantization by time which
means digitalization of the analog signal. The range of values which the signal can
achieve (quantization range) is divided into segments, each segment has a segment
representative of the quantization level which lies in the middle of the segment. To
every quantization segment (and quantization level) one and unique code word
(stream of bits) is assigned. The value that a signal has in certain time is called a
sample. The process of taking samples is called quantization by time. After
quantization by time, it is necessary to conduct quantization by amplitude.
Quantization by amplitude means that according to the amplitude of sample one
quantization segment is chosen (every quantization segment contains an interval of
amplitudes) and then record segments code word.
https://einstein.informatik.uni-oldenburg.de/rechnernetze/pcm.htm 1/14
8/31/22, 12:07 PM PCM
2 010
3 011
4 100
5 101
6 110
7 111
The first chart shows the process of signal quantizing and digitizing. The samples
shown are already quantized - they are approximated with the nearest quantization
level. To the right of each sample is the number of its quantization level. This number
is converted into a 3-bit code word using the above table.
The second chart shows the process of signal restoration.The restored signal is formed
according to taken samples. It can be noticed that the restored signal diverges from
the input signal. This divergence is a consequence of quantization noise. It always has
the same intensity, independent from the signal intensity. If the signal intensity drops,
the quantization noise will be more noticeable (the signal-to-noise ratio will drop).
The chart shows the reconstructed signal after compression. It still has the same basic
contours, but the distortions are greater due to coarser approximation - the
quantization noise has increased. This is due to the fact that the quantization step is
now double in size than with the uncompressed PCM.
In practice we have to decide which frequencies are relevant to our application and
which can be left out to achieve a reasonable size of the recording.
1 1,84
2 -0,08
3 -1,07
4 -0,02
5 0,42
6 1,80
7 1,30
8 1,00
9 -0,50
10 -1,12
The first step was to take values of signal in discrete time intervals, now it is time for
amplitude quantization.
In the first example code word was an binary form of quantization level (level: 3 code
word: 011 see table: related with first example).
Encoding in the second example is different, it will be explained below.
Fig1.
D - quantization step
------------------
D ¸ 2D 9
2D ¸ 3D 10
3D ¸ 4D 11
4D ¸ 5D 12
5D ¸ 6D 13
6D ¸ 7D 14
7D ¸ 8D 15
Segments are numbered in the way that segment 0 represents the lowest input
voltage range.
There are positive and negative values of an analog input signal so 1 bit of a code
word will be used to code the sign of the value and the other bits (3 in this example)
will represent a binary form of a discreet amplitude value which is determined by
quantization step.
The most significant bit(MSB) represents the sign of input value, and rest of code
word is a binary encoded number which was the result of amplitude quantization.
x - analog value
N - result of amplitude quantization
Code word: x is positive voltage so MSB is 1, three bits are binary coded result of
amplitude quantization (N=111).
So, code word in this case is : 1111
x - analog value
N - result of amplitude quantization
Code word: x is negative voltage so MSB is now 0, three bits are binary coded result
of amplitude quantization (N=101).
So, code word in this case is : 0101
As was presented the quantization level is the value which lies in the middle of the
segment. So every quantization level in this example has a belonging voltage
representative.In the following table quantization levels with belonging voltage
representatives and code words will be shown. So after a code word is calculated it is
possible to find in which quantization level the observed voltage lies.
It can be noticed that unlike first example the code word in general is not a binary
represented quantization level, positive values of quantization levels are just binary
representatives, while negative values are represented binary in different way which
corresponds to the encoding process. After we established the quantization levels and
belonging voltage representatives it can be shown how the example analog input is
quantized.
3 -1,07 4 0100
4 -0,02 7 0000
5 0,42 9 1001
6 1,80 14 1110
7 1,30 12 1100
8 1,00 11 1011
9 -0,50 6 0001
10 -1,12 3 0100
After quantization levels are formed we can see how the input signal is quantized and
digitized.
Finally, PCM encoded input signal in binary form looks like this:
1111 1110 0000 0100 0000 1001 1110 1100 1011 0001 0100
We used 44 bits to encode this signal.
If we want to restore the original signal we will have to follow the digital PCM
recording and using quantization levels representatives form an analog output.
Restoring a signal is shown in the chart below.
As it can be seen in Chart 3. that there is a slight divergence of restored signal from
the input signal.
This divergence is the result of quantization because the process of quantization is
followed by quantization noise.
Now, let's calculate quantization noise (as normalized power - defined for 1W)
Fig 2.
N - quantization noise
D - quantization step
L - number of segments (levels)
Quantization noise for our example:
Fig 3.
We should know the power of the signal which we don't so just to show approximately
how to calculate let's suppose that input signal is sinusoidal, then we could calculate
the signal to noise ratio.
The signal to noise ratio is usually expressed in dB.
S - signal, N - noise
n - number of bits
n=4:
The signal to noise ratio for sinusoidal signal and 4 bit PCM encoding.
https://einstein.informatik.uni-oldenburg.de/rechnernetze/pcm.htm 9/14
8/31/22, 12:07 PM PCM
Now, of course we must form PCM encoded table for our example by joining
quantization levels in Table 4.
3 4 2 001
4 7 3 000
5 9 4 100
6 14 7 111
7 12 6 110
8 11 5 101
9 6 3 000
10 3 1 010
It can be now shown how we form compressed signal joining neighborhood levels, as
described earlier in the text. The following chart will show how the signal is
compressed with halved quantization levels.
https://einstein.informatik.uni-oldenburg.de/rechnernetze/pcm.htm 11/14
8/31/22, 12:07 PM PCM
As it can be noticed divergence from original signal is now greater because the step of
quantization was doubled. The result of the compression is the increased quantization
noise.
We can now calculate it as in Fig2.
The result confirmed earlier showed the fact that quantization noise will be increased.
With the same assumption as in Fig3. we can calculate signal to noise ratio.
We can notice that the signal to noise ratio dropped because noise has been increased
by a process of compression.
In the following chart it will be shown how a signal with compression is formed which
includes reducing sampling frequency.
https://einstein.informatik.uni-oldenburg.de/rechnernetze/pcm.htm 12/14
8/31/22, 12:07 PM PCM
Chart 7. The restored signal and the signal before compression by reducing sampling
frequency
PCM encoded signal with compression by reducing sampling frequency in binary form:
1111 0001 1000 1101 1001 0010
After the compression signal is encoded with 24 bits, which means 45% reduction in
size and a1,833:1 compression ratio.
The restoration of signal after compression by reducing number of samples shows
divergence which is greater than after compression by reducing the number of
quantization levels. When compression by reducing number of samples was used the
divergence was caused by quantization noise which was caused by amplitude
quantization, in this case (compression by reducing number of samples) divergence is
caused by time quantization (remember we halved sampling frequency).
in data (images, etc.) and according to that to conduct the compression. Compression
of images is segment of data compression which was probably mostly exploited. So
image-compression based on the techniques described above can be called first
generation image coding techniques. The second generation image coding techniques
takes in consideration various aspects of human visual system in order to achieve
greater compression rates without significant loss of image quality. That means that
those coding techniques are lossy, but an important characteristic of this technique is
in that it identifies and separate visually relevant and irrelevant parts of an image and
then uses appropriate coding techniques for these parts.
https://einstein.informatik.uni-oldenburg.de/rechnernetze/pcm.htm 14/14