Professional Documents
Culture Documents
1. INTRODUCTION
Over the past decade, there has been a rapidly increase in the use of video in digital form.
This is due to the extensive use of the Internet world wide. Video can be seen as a sequence
of images which are displayed in order. Each of these images is called a frame. However,
there are minor changes in the consecutive frames such as a slight difference in the color.
Therefore, video compression standards do not encode all the information in the video.
some of this information are redundant and can be eliminated, some of them are not
important and may loss during the compression [1].
Video compression techniques can be classified to lossy and lossless compression
techniques. Lossless compression technique is used to encode computer originated data
files whereas lossy compression is used to encode audio, and video files. There are a variety
of lossy compression standards. The most widely implemented standards are MPEG-x
family, and H.26x family [2]. In this paper, the implementation of video MPEG codec was
performed and analyzed using MATLAB software.
1
Fgee et al
interface. It is a suite of standards for description and search of audio, visual and
multimedia content [3] – [6]
MPEG applies similar techniques as JPEG expect the prediction of motion. This is because
the video is a series of successive frames. Figure (1) illustrates the JPEG diagram. The
process starts with converting each frame into 𝑌𝐶𝑏𝐶𝑟 format, performing transformation
and quantization, and finally applying entropy coding via Run Length Encoding, and
Huffman algorithm
2. RELATED WORKS
Several studies have been carried out on video compression. For instance, performance
evaluation of entropy coding for MPEG-4 video codec was studied. In their paper, algorithm
for Context Adaptive Binary Arithmetic Coding (CABAC) is proposed for MPEG-4 Video
Codec. They stated that the compression efficiency can be up to 30% better when
compared to traditional entropy coding technique [4]. Performance analysis of various
video compression standards were examined in [5], between MPEG, and H.264.
In [6], performance analysis of various video compression techniques was carried out. They
compared MPEG-2, H.261, and H.264 video compression standards. the results showed
that the compression of H.264 is better than MPEG-2 and H.261.
In this study, the implementation and analysis of MPEG video codec was examined using
MATLAB. The following sections explain the MPEG compression steps, the experimental
procedure for implementing and analyzing MPEG by MATLAB, the discussion of obtained
results, and the finally the study conclusion.
2
Fgee et al
The encoding process of MPEG is performed in two main stages: first stage is to prepare
data for MPEG compression. This includes the resolution reduction of video frames which
results in dividing each frame into macroblocks.
The second stage is to apply MPEG compression on the prepared data. This stage includes:
applying motion predication at macroblocks level. Then, the Discrete Cosine
Transformation (DCT), quantization, and zig-zag operation are used to reduce the spatial
redundancy. Finally, the entropy coding using the Run Length Encoding (RLE) and the
Huffman coding algorithm are applied to the output of quantization [1] – [2].
Each frame (single image) in the video is represented in RGB model. This model must be
changed to a digital form in order to be compressed. RGB model must be changed to
𝑌𝐶𝑏 𝐶𝑟 model. Where Y is the luminance of the image that represents the brightness. 𝐶𝑏 is
the chrominance of the image that represents the difference between gray and blue
whereas 𝐶𝑟 is the chrominance of the image that represents the difference between gray
and red [7]. The following equation is used to covert the image from analog form (𝑌𝑈𝑉) into
digital form (𝑌𝐶𝑏 𝐶𝑟 ) [8].
3
Fgee et al
There are two system of 𝑌𝐶𝑏 𝐶𝑟 . The NTSC system which has resolution of 𝑌 = 352 ∗ 240 and
𝐶𝑏 = 𝐶𝑟 = 176 ∗ 120, and PAL system which has resolution of 𝑌 = 352 ∗ 288 and 𝐶𝑏 = 𝐶𝑟 =
176 ∗ 144 [9].
4
Fgee et al
blocks and sent to the DCT. The set of I frame, P frame, and B frame makes Group of
Picture GoP as shown in Figure (4) [2],[9].
3.2.3 QUANTIZATION
Quantization is defined as the process of reducing the number of bits needed to store an
integer value by reducing the precision of the integer. Quantization matrix is calculated by
5
Fgee et al
dividing each coefficient of the DCT output on the corresponding element of the
quantization table [1]. Equation (4) is used to calculate the quantized matrix.
𝑂𝑢𝑡𝑝𝑢𝑡 𝑜𝑓 𝐷𝐶𝑇
Quantized matrix = 𝑄𝑢𝑎𝑛𝑡𝑖𝑧𝑎𝑡𝑖𝑜𝑛 𝑡𝑎𝑏𝑙𝑒
(4)
The elements of quantization arrays are constant for luminance and chrominance as
shown in Table (1).
16 11 10 16 24 40 51 61 17 18 24 47 99 99 99 99
12 12 14 19 26 58 60 55 18 21 26 66 99 99 99 99
14 13 16 24 40 57 69 56 24 26 56 99 99 99 99 99
14 17 22 29 51 87 80 62 47 66 99 99 99 99 99 99
18 22 37 56 68 109 103 77 99 99 99 99 99 99 99 99
24 35 55 64 81 104 113 92 99 99 99 99 99 99 99 99
6
Fgee et al
0 0 --- 0 2 00
0/1 2 00 0/1 2 00
0/2 2 01 0/2 2 01
4. EXPERIMENTAL PROCEDURE
MPEG Codec introduced by [12] was implemented and further developed using MATLAB
[13]. In MPEG Codec the functions of Encoder.m and Decoder.m were based on other
7
Fgee et al
helper functions which was written to perform a specific task for Encoder or Decoder
function. Table (5) shows task for each helper functions.
Table (5): Helper function for MPEG codec [12]
Helper function Task
The MPEG codec reads uncompressed video and split it into frames in RGB format. The
RGB format is then converted to 𝑌𝐶𝑏𝐶𝑟 format. The luminance components that retains
maximum information is left out of the compression whereas high compression is applied
to chrominance components.
The Display.m function was added to MPEG codec in order to clearly identify each step of
MPEG compression. The README.m can be run to invoke the whole project.
In this study, Wildlife Windows 7 Sample Video found in [14] was compressed. The
uncompressed video was read and split into frames in RGB format. Figure (5a) shows the
original uncompressed frame in RGB format whereas Figures (5b) – (5d) show the original
uncompressed frame with the three colors red, green, and blue respectively. In order to
transform frame through DCT, it must be changed to 𝑌𝐶𝑏𝐶𝑟 format. Figure (6a) shows the
original frame in 𝑌𝐶𝑏𝐶𝑟 format. Figure (6b) shows the Luminance component of the frame
that represents brightness whereas Figure (6c) shows the variance chrominance between
gray and blue, and Figure (6d) shows the variance chrominance between gray and red.
After the frame is converted into a digital form 𝑌𝐶𝑏 𝐶𝑟 , it is divided into many blocks called
Macroblocks. The Macroblocks of 16*16 samples represent the luminance components
whereas Macroblocks of 8×8 represent the chrominance components.
8
Original Image in RGB format Red color in RGB format
Fgee et al
Original Image in RGB format Red color in RGB format
Green color
(a) Original in RGB
frame format
in RGB format (b)Blue color
Original in RGB
frame in Redformat
format
Chrominance Component
(a) Original frame (Cb)
in YCbCr format Chrominance
(d) LuminanceComponent
component Y (Cr)
Figure (6): (a) YCbCr format, (b) Luminance component Y, (c) Chrominance component Cb, (d)
Chrominance component Cr
Table (6) represents sample of chrominance component 𝐶𝑏 with Macroblock size of 8×8.
The values of Macroblock represented in Table (6) were processed by DCT in order to
produce DCT coefficients which are presented in Table (7). The output coefficients of DCT
9
Fgee et al
are further quantized to produce the quantized DCT coefficient which are presented in
Table (8). The assumption is that the quantization table of chrominance has a value of 14.
The values presented in Table (9) are the values of Macroblock (8×8) of chrominance
component Cb for reconstructed frame. These values are corresponded to the values of
Macroblock (8×8) of chrominance component Cb of the original frame presented in Table
(6).
Figure (7a) shows the reconstructed frame in 𝑌𝐶𝑏𝐶𝑟 format whereas Figure (7b) – (7d) show
Luminance and chrominance components (𝐶𝑏𝐶𝑟) for the reconstructed frame respectively.
In Figures (8a) – (8d), the reconstructed frame in RGB format with the three colors red,
green, and blue are presented.
10
Fgee et al
Figure (9) shows the difference between the original frame and the reconstructed frame. In
Reconstructed Image in YCbCr format Luminance Component Y
this study, the Peak Signal-to-Noise Ratio PSNR is used to measure the quality between
the original and a compressed image. PSNR was computed between the two frames shown
in Figure (9). The value of PSNR is 41.02. The higher the PSNR, the better quality of the
compressed, or reconstructed frame. Typical values for the PSNR (30 - 50)db []
Reconstructed Image in YCbCr format Luminance Component Y
(a) reconstructedComponent
Chrominance frame in YCbCr
(Cb) (b) LuminanceComponent
Chrominance component Y (Cr)
11
Reconstructed Image in RGB format Red color of Reconstructed Image
Fgee et al
Reconstructed Image in RGB format Red color of Reconstructed Image
Figure (8):Image
Original Reconstructed frame in: (a)Reconstructed
in RGB format RGB, (b) Red, Image
(c) Green, (d) format
in RGB Blue
Figure (9): comparison between: (a) Original frame, and (b) reconstructed frame
Original
Figure (10) shows the predicted motion vector which Image in with
is associated RGB frame
format presented in
figure (9a).
Motion Vector for Frame No. 8
60
40
20
0
0 10 20 30 40 50 60 70 80 90
Figure (10): The motion vector of the frame in figure (9a)
12
Fgee et al
6. CONCLUSION
In this study, an implementation of video MPEG codec was carried out. The results show
the process of MPEG compression starting from splitting the video into sequences frames,
converting each frame into 𝑌𝐶𝑏𝐶𝑟 format, applying motion prediction, performing
transformation and quantization, and finally applying entropy coding via Run Length
Encoding, and Huffman algorithm. The PSNR was used to measure the quality between
the original and reconstructed frames as the higher PSNR represents better quality of the
compressed frames. The average of PSNR was around 42.08.
7. REFERENCES
[1] Z., Fan, and D. R. Bull "Intelligent image and video compression: communicating pictures".
Academic Press, 2021.
[2] A D Marshall, "MPEG compression", available online at
https://users.cs.cf.ac.uk/dave/Multimedia/node255.html, accessed on 20/12/2022.
[3] F. Chad, D. J. LeGall, J. L. Mitchell, and W. B. Pennebaker. " MPEG video compression standard
", Springer Science & Business Media, 2007.
[4] R. Nigam, A. Mishra, A.K. Diwakar, " Performance evaluation of entropy coding for MPEG-4
video codec" International Advanced Research Journal in Science, Engineering and Technology,
Vol. 1, Issue 4, December 2014
[5] R. G. Deshpande and L. L. Ragha, "Performance analysis of various video compression
standards," International Conference on Global Trends in Signal Processing, Information
Computing and Communication (ICGTSPICC), Jalgaon, India, pp. 148-151, 2016.
[6] A. Gupta, D. Goyal, and N. Hemrajani " Performance Analysis of Various Video Compression
Techniques", International Journal of Science and Research (IJSR), Vol(2), Issue(8), pp 335 –
338, 2013.
[7] S. Asadollah, R. Bahrampour, M. S. Rostami, and M. A. Mobarhan. "Evaluation of Huffman and
arithmetic algorithms for multimedia compression standards." (IJCSEA), 2011.
[8] Discrete Cosine Transform and Image Compression part 1, available online at:
https://www.youtube.com/watch?v=gQHwvJ9Lvno, accessed on 29/12/2022.
[9] Motion Picture Expert Group, MPEG compression steps, available online at:
https://www.youtube.com/watch?v=lAkuix41XJ8, last accessed on 29/12/2022.
[10] MPEG Video Compression, available online at: http://www.bretl.com/mpeghtml/mpeg2vc.HTM
last accessed on 29/12/2022
[11] Image Compression Standards, available online at:
https://www.slideserve.com/rmoriarty/image-compression-standards-jpeg powerpoint-ppt-
presentation, last accessed on 29/12/2022
[12] C. Prabhudesai "MPEG/H.264/HEVC Video Codec in MATLAB", available online at
https://github.com/rite2hhh/MPEG-Codec last accessed on 21/12/2022
[13] MATLAB R2013a Student Version (32-bit), available on at:
https://uk.mathworks.com/matlabcentral/answers/98268-how-do-i-download-matlab-and-
other-mathworks-products, last accessed on 15/12/2022
[14] Wildlife Windows 7 Sample Video, available online at:
https://www.youtube.com/watch?v=a3ICNMQW7Ok, accessed on 31/12/2022
[15] K., Sergey, M. Zriakhov, V. Lukin, and B.Vozel. "MSE and PSNR prediction for ADCT coder
applied to lossy image compression." IEEE 9th International Conference on Dependable Systems,
Services and Technologies (DESSERT), pp. 613-618, 2018.
13