PCM - Pulse Code Modulation

Diese Site wurde kopiert von

http://www.rasip.fer.hr/research/compress/algorithms/fund/pcm/index.html

Was ist PCM?

PCM ist ein Methode, analoge in digitale Signale umzuwandeln.

## 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.

To conclude, PCM encoded signal is nothing more than stream of bits.

## The first example of PCM encoding

In this example the signal is quantized in 11 time points using 8 quantization segments. All the values that fall into a specific segment are approximated with the corresponding quantization level which lies in the middle of a segment. The levels are encoded using this table:

 Level Code word 0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111

Table1. Quantization levels with belonging code words

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. Chart 1. Quantization and digitalization of a signal

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). Chart 2. Process of restoring a signal.

PCM encoded signal in binary form:
101 111 110 001 010 100 111 100 011 010 101
Total of 33 bits were used to encode a signal.

## 1.Reducing number of quantization levels

The number of quantization segments can be reduced by joining two neighboring segments into one. This means that finally we will have 4 quantization segments unlike the previous case in which we had 8 segments. Four quantization segments can be coded using 2-bit code words, this will be shown in the table below.
 Level Code word 0 00 1 01 2 10 3 11

Table 2.  Quantization levels with belonging code words (after compression)

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. Chart 3. Compressed and restored signal with a restored sample

The compressed signal is PCM encoded as follows:
10 11 11 00 01 10 11 10 01 01 10
After compression we have 22 bits, that means 33% reduction in size with compression ratio of1.5:1 .

Practical use of this method
In practice, a PCM encoded audio signal is compressed at higher rates - for example, from 16 to 8 bits per sample (a rate of 2:1). This compression standard (called the A-law) uses nonlinear quantization. The quantization levels are not evenly distributed across the quantization range - they are denser near the zero level and sparser close to the maximum level. This way the quantization noise is reduced for lower-intensity signals.

## 2. Reducing the number of samples

Another basic method of compression is to reduce the number of samples. The number of samples can be reduced in the way that each two segments are replaced with one sample which is equal to their average. After the number of sample has been reduced in that way we halved number of samples which means that the sampling frequency has been halved. And because the bandwidth of the restored signal is directly proportional to the sampling frequency (B=0.5Fs), the net result is that it got halved as well. In our example this resulted in the loss of the highest frequency component of the signal: Chart 4. Compressed and restored signal with restored samples

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.

## The second example

The second example - a more quantitative approach to the PCM, meaning that in following text an approximate approach to the calculating will be shown.
An example of an analog signal is shown in the chart below. Chart 1.The example of analog signal

Now let's take values of analog signal in discrete time intervals.

 Time Analog signal value [V] 0 2,12 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

Table 1. Analog signal values taken in discrete time intervals

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. Um-maximum input voltage
L- number of quantization levels (n-number of encoding bits)

D - quantization step ------------------ Input voltage range[V] Segment -8D � -7D 0 -7D � -6D 1 -6D � -5D 2 -5D � -4D 3 -4D � -3D 4 -3D � -2D 5 -2D � -1D 6 -1D � 0 7 0 � D 8 D � 2D 9 2D � 3D 10 3D � 4D 11 4D � 5D 12 5D � 6D 13 6D � 7D 14 7D � 8D 15

Table 2. Input voltage intervals with belonging segments

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.

## FORMAT OF CODE WORD:  sign    3 bits represent binary code for result of amplitude quantization
1=+
0=-

Now, lets see example of coding two analog values:
Ex1.     x=2,10 [V]

D=0,275 [V] - value calculated in Fig 1. x - analog value
N - result of amplitude quantization - cuts of decimal places, example:  ( )

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

Ex2.     x=-1,64 [V]

D=0,275 [V] - value calculated in Fig 1. 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.

 Quantization level Voltage representative[V] Code word 0 -7,5D=-2,0625 0111 1 -6,5D=-1,7875 0110 2 -5,5D=-1,5125 0101 3 -4,5D=-1,2375 0100 4 -3,5D=-0,9625 0011 5 -2,5D=-0,6875 0010 6 -1,5D=-0,4125 0001 7 -0,5D=-0,1375 0000 8 0,5D=0,1375 1000 9 1,5D=0,4125 1001 10 2,5D=0,6875 1010 11 3,5D=0,9625 1011 12 4,5D=1,2375 1100 13 5,5D=1,5125 1101 14 6,5D=1,2375 1110 15 7,5D=2,0625 1111

Table 3. Quantization levels with belonging voltage representatives and code words

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.

 Time Analog signal value [V] Quantization level Code word 0 2,12 15 1111 1 1,84 14 1110 2 -0,08 7 0000 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

Table 4. PCM encoded input signal value

After quantization levels are formed we can see how the input signal is quantized and digitized. Chart 2. The input signal with digitized samples

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. Chart 3. Input signal and restored signal

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: More important than quantization noise is signal to noise ratio.

### 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.

## 1. Reducing numbers of quantization levels

The signal can be compressed if we reduce the number of quantization segments. We can reduce the number of segments from 16 to 8, so we will end up with 3 bit code words instead of 4.
We will join the two neighboring segments into one, it means that quantization step (D) will be doubled.According to Table 2. we will form Table 4. with 8 segments.

 Input voltage range[V] Segment -4D � -3D 0 -3D � -2D 1 -2D � -D 2 -D � 0 3 0 � D 4 D � 2D 5 2D � 3D 6 3D � 4D 7

Table 4. Input voltage range with the reduced number of segments Now, we can use a Table 3. to form a Table 5.

 Quantization level Voltage representative[V] Code word 0 -3,5D=-1,925 011 1 -2,5D=-1,375 010 2 -1,5D=-0,825 001 3 -0,5D=-0,275 000 4 0,5D=0,275 100 5 1,5D=0,825 101 6 2,5D=1,375 110 7 3,5D=1,925 111

Table 5. Quantization level, representative,code word for reduced number of segments(levels)

Now, of course we must form PCM encoded table for our example by joining quantization levels in Table 4.

 Time Quantization level w/o compression Quantization level with compression Code word (with compression) 0 15 7 111 1 14 6 110 2 7 3 000 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

Table 6.  PCM encoded signal values after compression

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. Chart 4. Compression by reducing number of quantization levels

PCM encoded compressed signal in binary form looks like this:
111 110 000 001 000 100 111 110 101 000 010
After compression we have 33 bits, which means 25% reduction in size and a 1,333 : 1 compression ratio.
Restoration of the original signal was shown on Chart 3., now in the chart below restoration of compressed signal is shown. Chart 5. Process of restoration (when compression is used)

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.

## 2. Reducing the number of samples

Reducing the number of samples is a second method of signal compression. This compression can be formed when two neighboring samples are replaced with one which is equal to their average.
The frequency of quantization by time is now halved (sampling frequency is halved) so the bandwidth of the restored signal got halved.
In our example this means that now we will have five instead of ten samples, that is shown in the table below.

 Time Quantization level Code word 0 15 1111 1 6 0001 2 8 1000 3 13 1101 4 9 1001 5 5 0010

Table 7. PCM encoded signal values after compression

In the following chart it will be shown how a signal with compression is formed which includes reducing sampling frequency. Chart 6. Compression by reducing sampling frequency 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).

## The final word

Today and in the future, research will be concentrated on developing new PCM signal compression methods. These compression methods should have higher compression rates, probably over 100:1 with unnoticeable loss in signal quality. The basic signal quality is measured by human perception, so various segments of human perception are being studied in detail. According to these studies compression methods are formed, the signal restored after compression has only components of the original signal which are above the threshold of perception. In the 80's compression methods was based on classical information theory. The basic technique was to find redundancy 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.