Adaptive media content architecture regarding users capabilities
Full text
TREBALL DE FI DE CARRERA TÍTOL DEL TFC: Adaptive media content architecture regarding users capabilities TITULACIÓ: Enginyeria Tècnica de Telecomunicació, especialitat Sistemes de Telecomunicació AUTOR: David Cuenca Gil DIRECTOR: Fco. Javier Iglesias Gracia SUPERVISOR: Xavier Miguelez Ortiz DATA: 18.06.09
Títol: Adaptive media content architecture regarding users capabilities Autor: David Cuenca Gil Director: Fco. Javier Iglesias Gracia Supervisor: Xavier Miguelez Ortiz Data: 18.06.09 Resum A continuació es presenta el projecte de fi de carrera “Adaptive media content architecture regarding users capabilities”. Avui dia, és comú que cada usuari tingui diferents capacitats de connexió i que cada contingut multimèdia tingui diferents requeriments. Per això, en aquest projecte s’estudia una primera aproximació de com adaptar el contingut multimèdia d’alta qualitat, emmagatzemat als repositoris, a les capacitats dels usuaris. S’estudiaran i s’implementaran diferents tècniques d’adaptació de vídeo al software anomenat UltraGrid. Aquest software és de distribució lliure i s’utilitza per transmissions de vídeo d’alta qualitat en temps real. Pot ser utilitzat com a sistema de videoconferència o de distribució. La principal característica de les tècniques d’adaptació de vídeo proposades en aquest projecte és que siguin aplicades en temps real. Aquesta adaptació podrà ser utilitzada, com es veurà més endavant, per diferents tipus d’aplicacions com, per exemple, fer una previsualització d’un vídeo d’alta resolució, agafar un flux de vídeo provinent d’una videoconferència i adaptar-lo a las capacitats de l’usuari, etc. Per comprovar que les diferents compressions tenen una qualitat acceptable pels objectius del projecte, s’utilitzaran dos tipus de mesures de qualitat de compressió de vídeo: objectiva i subjectiva. La qualitat objectiva serà mesurada amb el càlcul de la PSNR i la qualitat subjectiva serà representada per una eina desenvolupada durant aquest projecte. Finalment, les compressions resultants seran comparades amb les compressions de diferents sistemes estàndard, i es proposaran nous camins de recerca i possibles millores del sistema.
Title: Adaptive media content architecture regarding users capabilities Author: David Cuenca Gil Director: Fco. Javier Iglesias Gracia Supervisor: Xavier Miguelez Ortiz Date: June, 18th 2009 Overview In this document, the bachelor thesis called “Adaptive media content architecture regarding users capabilities” is presented. Nowadays, it is common that each user has different capabilities and each media content has different requirements. So, in this project will be studied a first approach of how to adapt the high quality media content, stored in the repositories, to the users capabilities. Different video adaptation techniques will be studied and implemented in the software named UltraGrid. It is an open source software used for real time transmissions of high definition video. It could be used as videoconference or as distribution system. The main characteristic of the video adaptation techniques purposed in this project is that those are applied at real time. This adaptation could be used for many application types, as could be seen then, as for example, make a preview from a high resolution video, take a videoconference flow and adapt it to the user capabilities, etc. To prove that the different compressions have an acceptable quality for the project objectives, will be used two types of video compression quality measuring: objective and subjective. The objective quality will be measured by the PSNR computation, and a tool developed during this project will represent the subjective quality. Finally, the obtained compressions will be compared with many standard system compressions, and new research lines and possible system improvements will be purposed.
ACKNOWLEDGEMENTS A mi madre, Laia Rovira, Antoni Serra, y todos aquellos amigos que me han apoyado y han confiado en mi desde el principio. A Francisco Iglesias por su constante apoyo, ayuda y correcciones durante todo el proyecto. A Xavier Miguelez por sus comentarios, correcciones y su confianza en mí. A Daniel Turull, Davide Vega y Pedro Lorente por su ayuda a la hora de realizar el proyecto y por su apoyo. Y a todas aquellas personas que hayan hecho posible este proyecto de una forma u otra. Gracias.
INDEX CHAPTER 1. INTRODUCTION.......................................................................... 1 CHAPTER 2. REVIEW OF THE STATE OF THE ART...................................... 2 2.1.V3 project...........................................................................................................................2 2.2.High definition television (HDTV)....................................................................................2 2.2.1.HD resolution.........................................................................................................3 2.2.2.HD frame rate and scan.........................................................................................3 2.2.3.Colour encoding.....................................................................................................4 2.2.4.HD bandwidth ........................................................................................................5 2.3.Software: UltraGrid (UG) ..................................................................................................6 2.4.The test scenario...............................................................................................................6 CHAPTER 3. MEASURE QUALITY TOOLS ..................................................... 9 3.1.Introduction.......................................................................................................................9 3.2.Objective quality: PSNR computation.............................................................................9 3.3.Subjective quality: error image......................................................................................11 CHAPTER 4. TECHNIQUES TO REDUCE THE BANDWIDTH ...................... 13 4.1.Frame rate reduction technique ....................................................................................13 4.2.S3 Texture Compression or DXT Compression...........................................................14 4.2.1.Introduction..........................................................................................................14 4.2.2.DXT1 compression ..............................................................................................14 4.2.3.DXT compression quality.....................................................................................16 4.3.Reducing image resolution technique..........................................................................18 4.3.1.Introduction. Frame structure...............................................................................18 4.3.2.2K (1920x1080) to K (960x540)...........................................................................19 4.3.3.2K (1920x1080) to PAL (720x576) ......................................................................27 4.3.4.2K (1920x1080) to PALplus (720x405)................................................................29 4.4.Reducing image resolution technique plus DXT Compression .................................34 4.4.1.Introduction. Frame structure...............................................................................34 4.4.2.2K (1920x1080) to K (960x540)...........................................................................35 4.4.3.2K (1920x1080) to PALplus (720x405)................................................................38 4.5.Throughput/quality comparative tables........................................................................40 4.6.Conclusions.....................................................................................................................43 CHAPTER 5. QUALITY COMPARISON WITH STANDARD SYSTEMS ........ 45 5.1. Introduction. Test HD image ..........................................................................................45
2 Adaptive media content architecture regarding users capabilities CHAPTER 2. REVIEW OF THE STATE OF THE ART In this chapter a short concepts list related to this project are described, concretely the European parent project, the basic concepts, the software involved and the test scenario that is going to be used. 2.1. V3 project This bachelor thesis is part of a European project called V3 [1] that is being developed by i2cat foundation [2]. V3 project (an abbreviation of Video, Videoconference and Visualization) is based on increasing demand of quality media contents and the necessity to share this quality content at real time for many application types. In this project is being implemented a transmission, reception and visualization platform with audiovisual contents independently of definition. So it is able to capture, send, receive and visualize from resolutions less than Standard Definition to super quality contents as Digital Cinema (HD, Quad HD…) or higher. Fig 2.1 V3 project final scenario 2.2. High definition television (HDTV) High definition television (or HDTV) [3] is part of several standards defined in digital television (or DTV). HDTV standard defines a new concept of digital television broadcasting system with higher resolution than traditional systems as PAL or NTSC, so is achieved better quality images. Another important change is that HDTV uses a panoramic display with 16:9 aspects. In this section a brief description of some HDTV concepts are going to be presented.
REVIEW OF THE STATE OF THE ART 3 2.2.1. HD resolution There are three different standard defined in HDTV standard with different resolutions and frame rate (frames per second). Those are HD ready (or 720p) with a resolution of 1280x720 pixels, Full HD (or 1080p/1080i) with 1920x1080 pixels, and SHD (or Quad HD) with four times more pixels than Full HD (3840x2160 pixels). In U.S. the format Full HD is named 2K and its resolution is 2048x1080 and Quad HD is named 4K with 4096x2160 pixels. Comparing PAL (720x576) with Full HD (1920x1080) is noted that the Full HD resolution is five times higher, so the image quality is five times higher too. In the following figure a real scale comparative of many standard resolutions that are going to be used in this project are presented. Fig 2.2 Real scale comparative of many standard resolutions 2.2.2. HD frame rate and scan Frame rate represents the number of frames per second that are reproduced by a video. This is an important parameter depending on the content of the video. When working with video contents without too much movement, as showing a galaxy or the mars planet, with a very low frame rate as 1 fps the video could be seen with a good subjective quality. This frame rate reduction could reduce so much the bandwidth requirements. There are two types of displaying images: 1. Progressive scanning (p): where each scan displays every line in the image sequentially from top to bottom. Possible frame rate are 23,98 / 24 / 25 / 29,97 / 30 / 60 depending of the zone.
4 Adaptive media content architecture regarding users capabilities 2. Interlaced scanning (i): where each scan displays alternate lines (even or odd per field) in the image raster, and two complete scans are therefore required to display the entire image. When this scan type is used, the audience note that there is so flicker. Possible field rate are 50 / 59,94 / 60. HD ready resolution (1280x720), in practice, always uses progressive scanning and this format is named 720p. On the other hand, Full HD resolution (1920x1080) usually use interlaced scanning to reduce the bandwidth requirements, this format is named 1080i. 2.2.3. Colour encoding The colour encoding is necessary for process the image through a computer. There are some theories about colour encoding, which only a few aspects from them are going to be described. RGB [4] is a colour model in which red, green and blue lights are added together to reproduce an extended colour space. This is the most well known colour model and it is usually used in electronic systems. Typical input devices are all type of cameras, TVs, scanners and output devices are LCD TVs, plasma TVs, etc. Fig 2.3 Image and its three RGB components RGBA [5] is another colour model similar to RGB. The difference is that RGBA has an extra information in the alpha channel. The alpha channel is normally used as an opacity channel; if a pixel has a value of 0% in its opacity channel, it is fully transparent, whereas a value of 100% in this channel gives a fully opaque pixel. The last colour model that is going to be described in this section is the YUV colour model [6]. It is closest to human model of image perception than RGB and RGBA. It is based on the characteristic that human’s eye is more sensible to luminance information (light intensity of a pixel) than to chrominance information (colour of a pixel). This allows reducing the bandwidth doing colour subsampling. It is composed by three components: Y is the luminance component; U and V are the chrominance components. The YUV colour model is used in PAL and NTSC standards that are the most common systems around the world as broadcasting television systems.
REVIEW OF THE STATE OF THE ART 5 As said before, the colour information is not the most important one, so it can be subsampled. Therefore there are different YUV encoding types depending on the subsampling applied. • YUV 4:4:4 keep intact the luminance and the colour information. • YUV 4:2:2 reduce sampling of the colour information by a half. • YUV 4:1:1 reduce sampling of the colour information by a quarter. The YUV 4:2:2 (or YUV422) encoding obtains near image quality to the RGB 4:4:4 encoding and it reduces the bandwidth by two-thirds, so it is normally used in the High Definition video. In many sections of this project this colour encoding is going to be used. Fig 2.4 Image and its three YUV components RGB to YUV formulas: Y=0,299R+0,587G+0,114B (2.1) U=0,492(BY)=0,147R0,289G+0,436B (2.2) V=0,877(RY)=0,615R0,515G0,100B (2.3) 2.2.4. HD bandwidth The bandwidth needed to assure that all the information can be transmitted at the same speed that is generated is computed using the next formula: BWHD =width height bits pixel fps (2.4) Replacing with the Full HD usually values; Full HD frame (1920x1080 pixels), YUV422 (2 bytes/pixel) and 30 frames per second there are obtained around 1 Gbps of throughput.
6 Adaptive media content architecture regarding users capabilities BWHD =1920 1080 pixels 1frame 2bytes 1pixel 8bits 1bytes 1Mb 106bits 30 frames 1s=995,33 Mb s1Gbps (2.5) 2.3. Software: UltraGrid (UG) The software that is going to be used in this project is the open source software named UltraGrid [7]. Initially developers were Ladan Gharai and Colin Perkins in the Information Sciences Institute East from University of Southern California [8]. This software is used for real time transmissions of high definition video. It could be used as videoconference system or as distribution system. It is the first system able to transmit uncompressed HD video over IP. UG is able to capture from one HD source, transmit the HD-SDI (SMPTE 292M) stream captured over IP network using RTP/UDP protocols, and visualize it using several solutions. It supports full rate uncompressed HD video at over 1.2 Gbps with minimal latency. For uncompressed HD, UltraGrid operates in two different modes: 8b/10b colour depth. One of those operates at just under 1 Gbps (for environment limited to 1 Gbps transport as Gigabit Ethernet connection) and the other at full rate HD mode of over 1.2 Gbps. 2.4. The test scenario Fig 2.5 The project test scenario
REVIEW OF THE STATE OF THE ART 7 The test scenario that is going to be used within this project is composed by the elements showed in the previous image. Concretely two TFT screens (Display scenario), two computers (UG RX and UG TX), one capture target (DVS Centaurus or AJA XENA), one RGB to HD-SDI converter (AJA Converter) and a SONY HD camera compose the project test scenario. In the transmission part, SONY HD camera is connected by RGB link to the RGB to HD-SDI converter and it is connected by BNC link to the capture target that is part of the UltraGrid TX (transmission computer). In the receiver part, the two screens are connected by DVI link to the UltraGrid RX (receiver computer). The two TFT displays are 1600x1200 pixels each one that adds 3200x1200 pixels. Is necessary to use two TFT displays due to one is only able to display 1600x1200 pixels and HD images are 1920x1080 pixels. The transmission and the reception part are connected by a GE link. The video is captured from the SONY HD camera with a colour component output. The three RGB component signals are converted to a HD-SDI stream using AJA Converter and then sent to the UltraGrid TX by the DVS Centaurus or the AJA XENA cards. Is needed the AJA Converter due to the camera has not a HD-SDI output. There are cameras with HD-SDI output but them are very expensive. HD video flow (1920x1080 pixels) is transmitted from the UltraGrid TX to the UltraGrid RX coded by YUV422 with 8-bit colour depth and at 30 frames per second. The result of this configuration is a throughput of around 1 Gbps. To check the compression quality of the different compressions that are going to be purposed within this project, instead SONY HD camera video flow, a test HD image presented in the following figure is going to be used. Fig 2.6 Test HD image
8 Adaptive media content architecture regarding users capabilities In the receiver computer (UG RX) the received flow is painted with a SDL (Simple Direct media Layer) display [9]. SDL is a set of libraries developed in C language to provide basic functions for 2D drawing operations apart from other functions.
MEASURE QUALITY TOOLS 9 CHAPTER 3. MEASURE QUALITY TOOLS 3.1. Introduction Nowadays, to perform a good measure of image and video compression quality is not a simple task. The best possible measure would be the one that gives us a value as close as possible to the interpretation of the human brain. So the relevant information of an image is the one perceptible for the human visual system, for this reason is needed to analyze the characteristics of biological image processing and then point out the relation between the biological and the digital images. Therefore there are two types of image compression quality measuring: objective and subjective. The objective quality is a kind of measure that is computed taking into account only objective parameters, i.e. the differences between pixels from the original and the compressed image. On the other hand, the subjective quality is a kind of measure that is based on the human perception of images as the main parameter. For example, is known that the human visual system is more sensitive to luminance than to colour information, so if there are an error value in the luminance channel, a tool of objective quality will show the same results as having the same error in the colour channel, and it would not be the same error level for the human brain. Some companies are developing tools to measure the subjective quality of image compression, also ITU-R [10] is developing recommendations on subjective quality assessment methodologies [11], but today there is not a reliable tool for this task. In this project, to know that the image compression quality is acceptable for the project objectives is needed, but not extremely accurate for the real subjective quality. So, within this project an objective quality parameter will be measured and a subjective quality tool that allows the user to evaluate the subjective quality compression, as an intuitively form, will be developed. Is needed to say that this subjective quality tool there is not able to give the user a value that measures the real subjective quality, but is able to allow that the user can evaluate the subjective quality by himself, as would be seen in the following chapters. 3.2. Objective quality: PSNR computation The objective quality parameter used in this project is the PSNR (Peak Signal to Noise Ratio) [12]. PSNR is the ratio between the maximum possible power of a signal and the power of corrupting noise that affects the fidelity of its representation. Common use of the PSNR is as a tool of objective quality to quantify reconstruction quality of a compression codec, for example, image compression. In this case, the signal is the original image and the noise is the error introduced by the compression.
10 Adaptive media content architecture regarding users capabilities The formula of PSNR is: PSNR(dB)=20log10 MAXI MSE (3.1) where MAXI is the maximum value that can achieve a pixel component and MSE is Mean Squared Error [13]. PSNR is expressed by decibels. This two unknown values are calculated as follows. Eight bits per component are used, so the maximum value that a pixel component can achieve is: MAXI=281=255 (3.2) The formula of MSE is: MSE =1 MNsx,y () st(x,y) [] 2 x=0 N1 () y=0 M1 () (3.3) where M, N are the long and wide of the image, s(x,y) is the original signal and st(x,y) is the reconstructed signal. If HD values are introduced, using YUV422 coding (2 bytes per pixel): MSE =1 192021080 sx,y () s t (x,y) [] 2 x=1 10801 () y=1 192021 () (3.4) With the comparison of two identical images it is obtained a MSE value equal to 0 and then the PSNR value is infinite. For this reason, the smaller MSE the higher PSNR and it means that the better compression quality is achieved. So the worse PSNR is 0 dB, as a result, for example, of a comparison between white and black images. It is considered that 20 dB of PSNR is a bad level, 30 dB is a good level and 40 dB is a very good level. For PSNR computation two images with the same number of pixels are needed due to this computation is performed pixel by pixel as can be seen in the previous formulas. As will be described in the chapter 4, one of the compressions techniques applied outcomes a reduced resolution image. This smaller image must be resized (using any well-known professional image software such as Photoshop) to the original resolution to perform the PSNR
MEASURE QUALITY TOOLS 11 between them. Those formulas have been fitted in a new module in the software named UltraGrid. 3.3. Subjective quality: error image As explained in the introduction section, a subjective quality tool that allows the user to evaluate subjective quality compression, as an intuitively form, has been developed. It is a graphical application able to draw the error between the original and the compressed images by a greyscale. This toll has been fitted for the software named UltraGrid too. The formula to draw the error is presented as follows: s'x,y () =255 abs s x,y () st(x,y) [] (3.5) where s(x,y) is the original signal, st(x,y) is the compressed signal and s’(x,y) is the resultant greyscale error image. This formula is applied to the luminance channel that is the most important one for the human visual system. Number 255 is needed for setting up the white colour as base colour, i.e. white colour is painted if there is no error. Darker colour is painted when there is higher error. To show a small preview of the functionality of this tool, a comparison between a test image and the same test image modified inserting three green squares is shown. Fig 3.1 Test image
18 Adaptive media content architecture regarding users capabilities MSE =1 MNsx,y () st(x,y) [] 2 x=1 N y=1 M =1 192021080 239028094 x=1 1080 =57,64 y=1 19202 (4.9) PSNR(dB)=20log10 MAXI MSE =20log10 255 57,64 = 30,52dB (4.10) Fig 4.5 The error between the test HD image and the test HD image compressed with DXT As said in the chapter 3, it is considered that 20dB of PSNR is a bad level, 30 dB is a good level and 40dB is a very good level. Therefore, as seen in the results, this compression has a good compression quality (30,52 dB). 4.3. Reducing image resolution technique Another technique to reduce the bandwidth is reducing the image resolution. In this section many types of transcodifications applied to reduce the resolution of the image are described. 4.3.1. Introduction. Frame structure Before explaining the reduce resolution techniques is needed to describe the frame structure that is used in this kind of video flows. As said before, in this environment HD frames coded by YUV422 are used.
TECHNIQUES TO REDUCE THE BANDWIDTH 19 Fig 4.6 HD frame coded by YUV422 As explained during the chapter 2 and as could be seen in the figure 4.6, YUV422 keep intact the luminance and reduces the colour sampling by a half, so two adjacent pixels to recompose all information are needed. 4.3.2. 2K (1920x1080) to K (960x540) The first resolution adaptation technique that is going to be described is how to convert from 2K (1920x1080) to K (960x540), due to it is the simplest conversion of all that are going to be fitted in the UltraGrid software. Reduction factor: Horizontal =1920 pixels 960 pixels =2 (4.11) Vertical =1080 pixels 540 pixels =2 (4.12) So to convert from 2K to K is needed to reduce the horizontal pixels by a half and the vertical pixels by a half, so in total by a quarter. This has been fitted with three different types of transcodification. One of those is just removing pixels, another one doing vertical average and the last one doing an average between adjacent pixel-blocks. 1. Removing pixels: removing one of each two pixels per line and two of each four pixels per column, i.e. removing six of each eight pixels, as shown in the following figure.
20 Adaptive media content architecture regarding users capabilities Fig 4.7 2K to K removing pixels 2. Doing vertical average: here for each four original pixels (2x2 block) one pixel is taken as output. The four luminance bytes of each block are taken and their average is done. With the colour bytes alternating from U to V in each block to keep the frame structure and doing their average too, as shown in the below figure: Fig 4.8 2K to K doing vertical average 3. Doing average between adjacent pixel-blocks: this type is very similar to the previous one. The difference is that the colour bytes that before do not use now are used in the adjacent 4-pixel block.
TECHNIQUES TO REDUCE THE BANDWIDTH 21 Fig 4.9 2K to K doing average between adjacent pixel-blocks Before using the tool developed in this project to measure the quality of the compressions, we zoom into a specify area in the three compressed images by the three compression methods described. Fig 4.10 400% zoom applied to the K image reduced by removing pixels
22 Adaptive media content architecture regarding users capabilities Fig 4.11 400% zoom applied to the K image reduced by doing vertical average Fig 4.12 400% zoom applied to the K image reduced by doing average between adjacent pixel-blocks In the 400% zoom applied to the K image reduced by removing pixels is noted that the outlines are the most affected due to this information is lost with this technique. So, with the average reduction types is achieved an improvement of this information. Now it is time to compare those compressions with the PSNR computation and drawing the error, in order to see the subjectively effects in the image quality.
TECHNIQUES TO REDUCE THE BANDWIDTH 23 1. PSNR of the removing pixels technique: MSE =1 MNsx,y () st(x,y) [] 2 x=1 N y=1 M =1 192021080 93722179 =22,60 (4.13) PSNR(dB)=20log10 MAXI MSE =20log10 255 22,60 = 34,59dB (4.14) 2. PSNR of the doing vertical average technique: MSE =1 MNsx,y () st(x,y) [] 2 x=1 N y=1 M =1 192021080 50950316 =12,29 (4.15) PSNR(dB)=20log 10 MAX I MSE =20log 10 255 12,29 = 37,24dB (4.16) 3. PSNR of the doing average between adjacent pixel-blocks technique: MSE =1 MNsx,y () st(x,y) [] 2 x=1 N y=1 M =1 192021080 36409343 =8,78 (4.17) PSNR(dB)=20log 10 MAX I MSE =20log 10 255 8,78 = 38,70dB (4.18) As can be seen in the results, those compressions have a very good quality level. Comparing removing pixels with doing vertical average is noted that the PSNR increases 2,65 dB and comparing doing vertical average and doing average between adjacent pixel-blocks the PSNR increases 1,46 dB; these two values are so high to take them into account. To get an idea, MPEG committee use a threshold of 0,5 dB increase of PSNR to decide whether to include an improvement in a specific encoding algorithm, as it is considered that these increases of PSNR is visually significant.
24 Adaptive media content architecture regarding users capabilities Fig 4.13 The error between 2K image and K image removing pixels Fig 4.14 The error between 2K image and K image doing vertical average
TECHNIQUES TO REDUCE THE BANDWIDTH 25 Fig 4.15 The error between 2K image and K image doing average between adjacent pixel-blocks At the error images could be seen the same that is presented at the PSNR formulas, i.e. the increases of the PSNR that signify the reduction of the error. The error image of removing pixels shows the outlines of the original image due to with this technique this information is lost, as said before. Comparing the error image of removing pixels with the error image of doing vertical average is noted that is achieved a significant reduction of these losses. Finally, at the error image doing average between adjacent pixel-blocks is difficult to see any error. Therefore, taking into account only quality parameters is obvious that always the conversion that will be used, will be the conversion with the better compression quality, but no always it can be used. Depending on the computer, it could be able to process less or more operations per second, and depending on the type of the compression the operations per second increases. For this reason, now an approximate computation of the CPU time required for every one of the compressions purposed is going to be presented. The conversion is processed for each frame, so the computer has to process the conversion 30 times per second. Assuming the ideal case where the overall time used to do an operation is the 2 operation CPU time, using a 3 GHz CPU: Estimated number of operations to do the compression of one frame (see more in ANNEX B): 1. Removing pixels: 540 480 9+540 =2333340operations frame (4.19)
26 Adaptive media content architecture regarding users capabilities 2. Doing vertical average: 540 480 21 =5443200operations frame (4.20) 3. Doing average between adjacent pixel-blocks: 540 480 25 =6480000operations frame (4.21) So, the percentage of the CPU time using a 3 GHz CPU and assuming the ideal case where a sum require only 2 operations per second: 1. Removing pixels: 2333340 sums frame 3109operations s 30 frames s2operations sum 100 =4,67% (4.22) 2. Doing vertical average: 5443200 sums frame 310 9 operations s 30 frames s2operations sum 100 =10,89% (4.23) 3. Doing average between adjacent pixel-blocks: 6480000 sums frame 310 9 operations s 30 frames s2operations sum 100 =12,96% (4.24) So, depending on the computer that will process the video adaptation, it could be able to do one or another compression. Note that there is a connection between the CPU needed and the quality of the compression, i.e. the compression with the better quality is the compression that needs more operations per second.
TECHNIQUES TO REDUCE THE BANDWIDTH 27 4.3.3. 2K (1920x1080) to PAL (720x576) Now how to convert from 2K (1920x1080) to PAL (720x576) is going to be described. The reason of choosing PAL standard is due to it is the most common broadcasting TV standard in Europe. Reduction factor: Horizontal =1920 pixels 720 pixels 1920 240 pixels 720 240 pixels =8pixels 3pixels (4.25) Vertical =1080 pixels 576 pixels = 1080 72 pixels 576 72 pixels =15 pixels 8pixels (4.26) So to convert from 2K to PAL is needed to reduce from eight pixels to three horizontally and from fifteen pixels to eight vertically. 1. Removing pixels: removing five of each eight pixels horizontally and seven of each fifteen pixels vertically. As could be seen in the following figures, alternate from the first, the fourth and the seventh pixels (1), and the second, the fifth and the eighth pixels (2), is needed to keep the frame structure. Fig 4.16 2K to PAL removing pixels, horizontal (1)
34 Adaptive media content architecture regarding users capabilities Fig 4.26 The error between 2K image and PALplus image doing average 4.4. Reducing image resolution technique plus DXT Compression In this chapter how to apply reduce image resolution technique and DXT compression at the same time is going to be explained. Both techniques couldn’t be applied simultaneously by the way that was explained before, due to having DXT compression RGBA flows are used and with reducing resolution technique YUV flows are used, so how to apply simultaneously is going to be described now. 4.4.1. Introduction. Frame structure Now, instead YUV422, frame structure has RGBA encoding. The HD frame structure is shown at the following figure: Fig 4.27 HD frame coded by RGBA
TECHNIQUES TO REDUCE THE BANDWIDTH 35 4.4.2. 2K (1920x1080) to K (960x540) The first resolution adaptation technique that is going to be described is how to convert from 2K (1920x1080) to K (960x540) as was made in the previous section. Reduction factor: Horizontal =1920 pixels 960 pixels =2 (4.33) Vertical =1080 pixels 540 pixels =2 (4.34) So to convert from 2K to K is needed to reduce the horizontal pixels by a half and the vertical pixels by a half, so in total by a quarter. This had been fitted with two different types of transcodification. One of those is just removing pixels and the other one doing an average. 1. Removing pixels: removing one of each two pixels per line and two of each four pixels per column, i.e. removing six of each eight pixels, as shown in the below figure. Fig 4.28 2K to K removing pixels with a RGBA flow 2. Doing average: here for each four input pixels (2x2 block) one pixel output. In this section is simplest that having YUV flows due to here there are not colour subsampling, so just is needed to do the average with every components.
36 Adaptive media content architecture regarding users capabilities Fig 4.29 2K to K doing average with a RGBA flow Now it is time to compare those compressions with the PSNR computation and drawing the error, in order to see the subjectively effects in the image quality. 1. PSNR of the removing pixels technique: MSE =1 MNsx,y () st(x,y) [] 2 x=1 N y=1 M =1 192021080 526318927 =126,91 (4.35) PSNR(dB)=20log 10 MAX I MSE =20log 10 255 126,91 = 27,10dB (4.36) 2. PSNR of the doing average technique: MSE =1 MNsx,y () s t (x,y) [] 2 x=1 N y=1 M =1 192021080 227189154 =54,78 (4.37) PSNR(dB)=20log 10 MAX I MSE =20log 10 255 54,78 = 30,74dB (4.38)
TECHNIQUES TO REDUCE THE BANDWIDTH 37 As seen at the results, those compressions have a good quality level. Comparing removing pixels with doing average is noted that PSNR increases 3,64 dB that is so high to take it into account. Fig 4.30 The error between 2K image and 2K image reduced to K by removing pixels and compressed with DXT Fig 4.31 The error between 2K image and 2K image reduced to K by doing average and compressed with DXT In the error images could be seen the same that is presented at the PSNR formulas, i.e. the increases of the PSNR that signify the reduction of the error. It
38 Adaptive media content architecture regarding users capabilities is observed an improvement from the removing pixels error image to the doing average image error in the entire image. 4.4.3. 2K (1920x1080) to PALplus (720x405) To convert from 2K to PALplus is the same process than before, i.e. reducing from eight pixels to three horizontally and from eight lines to three vertically. Before was explained by the figures because it was more difficult to explain due to the colour subsampling, but now is easier due to we have all information of all pixels. This had been fitted with two different types of transcodification as before. One of those is just removing pixels and the other one doing an average. 1. Removing pixels: both horizontal and vertical conversions are applied by the same rule. Eight pixels/lines are taken; all are removed but the first, the fourth and the seventh. With this the best uniformity that can be fitted is achieved. 2. Doing average: both horizontal and vertical conversions are applied by the same rule too. Eight pixels/lines are taken and there is made an average from the first, the second and the third pixels/lines, from the fourth, the fifth and the sixth pixels/lines, and from the seventh and the eighth pixels/lines. Now it is time to compare those compressions with the PSNR computation and drawing the error, in order to see the subjectively effects in the image quality. 1. PSNR of the removing pixels technique: MSE =1 MNsx,y () s t (x,y) [] 2 x=1 N y=1 M =1 192021080 1023134689 =246,70 (4.39) PSNR(dB)=20log 10 MAX I MSE =20log 10 255 246,70 = 24,21dB (4.40) 2. PSNR of the doing average technique: MSE =1 MNsx,y () s t (x,y) [] 2 x=1 N y=1 M =1 192021080 974620048 =235,01 (4.41)
TECHNIQUES TO REDUCE THE BANDWIDTH 39 PSNR(dB)=20log10 MAXI MSE =20log10 255 235,01 = 24,42dB (4.42) As seen at the results, those compressions have a regular quality level, not bad not well. For the project objectives, we consider that those values are the minimum acceptable quality to make the video adaptation. Comparing removing pixels with doing average is noted that PSNR increases 0,21 dB that is a low value that does not improvement the image quality. As could be seen in the below error images, the difference between them is negligible. As said before MPEG committee use a threshold of 0,5 dB increase of PSNR to decide whether to include an improvement in a specific encoding algorithm, as it is considered that these increases of PSNR is visually significant, so in this case this improvement from removing pixel to doing average do not achieves this threshold. Fig 4.32 The error between 2K image and 2K image reduced to PALplus by removing pixels and compressed with DXT
40 Adaptive media content architecture regarding users capabilities Fig 4.33 The error between 2K image and 2K image reduced to PALplus by doing average and compressed with DXT 4.5. Throughput/quality comparative tables In this section the throughput and the quality of the different techniques described in this chapter are going to be compared. First a table combining DXT compression, reduction of resolution technique and the combination of both is presented. Then in the second table is introduced reduction of fps technique to all one presented in the first. Table 4.2 Throughput and quality comparative table comparing DXT compression, reduction of resolution technique and the combination of both Resultant format Resolution 1) Fps 2) DXT 3) Reduction of resolution? Colour encoding Pixels/ frame Bytes/frame Throughput (Mbps) PSNR (dB) No No 2073600 4147200 995,33 2K 1920x1080 30 Yes No YUV 4:2:2 518400 1036800 248,83 30,52 No Yes, removing pixels 518400 1036800 248,83 34,59 No Yes, doing vertical average 518400 1036800 248,83 37,24 No Yes, doing average between adjacent pixels 518400 1036800 248,83 38,70 Yes Yes, removing pixels 129600 259200 62,21 27,10 K 960x540 30 Yes Yes, doing average YUV 4:2:2 129600 259200 62,21 30,74 No Yes, removing pixels 414720 829440 199,07 36,76 PAL 720x576 30 Yes Yes, removing pixels YUV 4:2:2 103680 207360 49,77 25,43 No Yes, removing pixels 291600 583200 139,97 35,45 No Yes, doing average 291600 583200 139,97 35,89 Yes Yes, removing pixels 72900 145800 34,99 24,21 PALplus 720x405 30 Yes Yes, doing average YUV 4:2:2 72900 145800 34,99 24,42
TECHNIQUES TO REDUCE THE BANDWIDTH 41 Table 4.3 Throughput and quality comparative table comparing DXT compression, reduction of resolution technique, fps reduction technique and the combination of them Resultant format Resolution 1) Fps 2) DXT 3) Reduction of resolution Colour encoding Pixels/frame Bytes/frame Throughput (Mbps) PSNR (dB) 30 No No 2073600 4147200 995,33 20 No No 2073600 4147200 663,65 10 No No 2073600 4147200 331,78 30 Yes No 518400 1036800 248,83 30,52 20 Yes No 518400 1036800 165,89 30,52 2K 1920x1080 10 Yes No YUV 4:2:2 518400 1036800 82,94 30,52 30 No Yes, removing pixels 518400 1036800 248,83 34,59 20 No Yes, removing pixels 518400 1036800 165,89 34,59 10 No Yes, removing pixels 518400 1036800 82,94 34,59 30 No Yes, doing vertical average 518400 1036800 248,83 37,24 20 No Yes, doing vertical average 518400 1036800 165,89 37,24 10 No Yes, doing vertical average 518400 1036800 82,94 37,24 30 No Yes, doing average between adjacent pixel-blocks 518400 1036800 248,83 38,70 20 No Yes, doing average between adjacent pixel-blocks 518400 1036800 165,89 38,70 10 No Yes, doing average between adjacent pixel-blocks 518400 1036800 82,94 38,70 30 Yes Yes, removing pixels 129600 259200 62,21 27,10 20 Yes Yes, removing pixels 129600 259200 41,47 27,10 10 Yes Yes, removing pixels 129600 259200 20,74 27,10 30 Yes Yes, doing vertical average 129600 259200 62,21 30,74 20 Yes Yes, doing vertical average 129600 259200 41,47 30,74 K 960x540 10 Yes Yes, doing vertical average YUV 4:2:2 129600 259200 20,74 30,74 30 No Yes, removing pixels 414720 829440 199,07 36,76 20 No Yes, removing pixels 414720 829440 132,71 36,76 10 No Yes, removing pixels 414720 829440 66,36 36,76 30 Yes Yes, removing pixels 103680 207360 49,77 25,43 20 Yes Yes, removing pixels 103680 207360 33,18 25,43 PAL 720x576 10 Yes Yes, removing pixels YUV 4:2:2 103680 207360 16,59 25,43 30 No Yes, removing pixels 291600 583200 139,97 35,45 20 No Yes, removing pixels 291600 583200 93,31 35,45 10 No Yes, removing pixels 291600 583200 46,66 35,45 30 No Yes, doing vertical average 291600 583200 139,97 35,89 20 No Yes, doing vertical average 291600 583200 93,31 35,89 10 No Yes, doing vertical average 291600 583200 46,66 35,89 30 Yes Yes, removing pixels 72900 145800 34,99 24,21 20 Yes Yes, removing pixels 72900 145800 23,33 24,21 10 Yes Yes, removing pixels 72900 145800 11,66 24,21 30 Yes Yes, doing vertical average 72900 145800 34,99 24,42 20 Yes Yes, doing vertical average 72900 145800 23,33 24,42 PALplus 720x405 10 Yes Yes, doing vertical average YUV 4:2:2 72900 145800 11,66 24,42 The minimum PSNR value is 24,21 dB that it is a regular value, not bad not good. But as said before, we consider that this is the minimum acceptable value for the project objectives. Note that without reduction of frame rate technique, a reduction from 995,33 Mbps of the original video throughput to 34,99 Mbps of the compressed video throughput is achieved. With this compression (DXT compression plus PALplus
42 Adaptive media content architecture regarding users capabilities resolution) is achieved to reduce the video to a 3,52 % from the original size keeping the 30 frames per second. If the video content allows to reduce to 10 fps keeping a good user experience, is achieved to transmit this video with 11,66 Mbps of throughput that is the 1,17 % from the original one. Comparing DXT compression with reduction to K resolution technique is achieved the same throughput (248,83 Mbps) due to the two compressions reduce the original video size by a quarter. But the PSNR of DXT compression is 30,52dB and the PSNR of reduction to K resolution technique doing average between adjacent pixel-blocks is 38,70dB. The difference is 8,18 dB that is a very high value, so the conclusion is that if the user could receive 248,83 Mbps is better to use reduction to K resolution technique than DXT compression. In the next two figures are compared the two compressions mentioned with the error images, note the significant difference in the quality. Fig 4.34 The error between 2K image and 2K image compressed with DXT
TECHNIQUES TO REDUCE THE BANDWIDTH 43 Fig 4.35 The error between 2K image and K image doing average between adjacent pixel-blocks Another conclusion that can be taken observing the tables, is that the average conversions improve the quality than the removing one, especially in the images with K resolution and not so much in the images with PALplus resolution. 4.6. Conclusions First proved in this chapter is that the frame rate is a very significant parameter at the time of adapting the video to the user capabilities. It could be reduced especially in the video contents without to much movements, so in this cases is important to reduce the frame rate at maximum possible, but keeping a good user experience. As seen in the 4.2 section, the DXT compression achieves a good objective and subjective quality reducing by a quarter the bandwidth, so the original 1 Gbps is converted to 250 Mbps keeping 2K resolution. But the compression could be applied to any resolution, so it allows compressing the K and the PALplus images reducing still more the bandwidth. As seen in the section 4.3.2, with the technique of reducing the resolution of the image, the better quality compressions are logically which uses more information to perform the resultant image, but is necessary to know the characteristics of the computer to know what type of compressions is able to process. The operations per second increases at the time that increases the complexity of the compression.
50 Adaptive media content architecture regarding users capabilities Fig 5.6 The error between 2K and PALplus image compressed by Paint Fig 5.7 The error between 2K and PALplus image compressed by Photoshop Now the better of the reduction to PALplus resolution techniques purposed (doing average) has a little more quality than to PALplus compression of the professional image editors. The PSNR of the project technique is 0,88dB higher than to Paint compression and 0,62dB higher than to Photoshop compression. The reason that the technique purposed in this project has better quality is due to it is customized specifically to the case to convert from 2K to PALplus, not as Paint and Photoshop.
QUALITY COMPARISON WITH STANDARD SYSTEMS 51 5.3. Comparison with DVTS DVTS (Digital Video Transport System) [18] is an open source software able to transmit DV (Digital Video) [19] streams from IEEE1394 over RTP/IP. The result of this configuration, if working with PAL resolution, is a throughput about 30 Mbps and 2/3 seconds of latency. DV is a digital video format created by Sony, JVC, Panasonic and other video camera producers, and launched in 1995. The DV standard is usually used in the professional edition. In this section, the DV compression and the compression used in this project (DXT compression) will be compared. To compare the quality compression are going to be used the PSNR computation and drawn the error tool as in the previous chapters. Booth compressions are going to be applied to the PALplus image achieved with the better of the reduction resolution purposed, to be in the same conditions. PSNR of the DXT compression applied to the PALplus image: MSE =1 MNsx,y () s t (x,y) [] 2 x=1 N y=1 M =1 192021080 2167895155 =522,74 (5.13) PSNR(dB)=20log10 MAXI MSE =20log10 255 522,74 = 20,95dB (5.14) PSNR of the DV compression applied to the PALplus image: MSE =1 MNsx,y () s t (x,y) [] 2 x=1 N y=1 M =1 192021080 1996853125 =481,49 (5.15) PSNR(dB)=20log 10 MAX I MSE =20log 10 255 481,49 = 21,30dB (5.16)
52 Adaptive media content architecture regarding users capabilities Fig 5.8 The error between 2K and PALplus image compressed by DXT compression Fig 5.9 The error between 2K and PALplus image compressed by DV compression At the error images is noted that applying DXT compression, the outlines are the most affected as said before, because this compression affects especially to its. But, seeing the error image applying DV compression is noted that this compression do not affect outlines very much, but the error is present in the entire image due to the nature of the compression that is based on DCT transformation [20].
QUALITY COMPARISON WITH STANDARD SYSTEMS 53 Table 5.1 Throughput and quality comparative table comparing DV and DXT compressions Format Resolution Colour encoding Frame rate (fps) Pixels/frame Compression Compression ratio Bytes/frame Throughput (Mbps) PSNR (dB) PALplus 720x405 YUV 4:2:2 30 291600 DXT 4:1 145800 34,99 20,97 PALplus 720x405 YUV 4:2:0 30 291600 DV 5:1 87480 21,00 21,30 As can be seen in the previous results DXT compression has an enough similar quality value to DV compression, but the throughput is about 60 % higher. In terms of latency, DV compression adds 2/3 seconds of latency and DXT compression is applied at real time.
54 Adaptive media content architecture regarding users capabilities CHAPTER 6. VIDEO ADAPTATION APPLICATIONS 6.1. Teacher in an astronomy congress A teacher is going to talk in an astronomy congress and he wants to download one HD video from a repository to show it to the audience. He will probably have three problems at the time to know if the video that he will download is which he wants: recourses, time and display. Recourses due to download this video he will probably require reserving an amount of recourses, time due to the download will spend so much time and display due to he will need an HD display at the time to see that the downloaded video is which he wants. So, the preview make with the video adaptation techniques purposed in this project allows him to solve those problems. About recourses, with the preview is achieved a reduction of the recourses needed. About time, this problem is solved completely due to the preview is made at real time. And about display, he will only need, for example, a laptop that certainly will have, and if not, he can achieve easily. In the following image could be seen a preview from HD flow using DXT compression and reduction of resolution technique to PALplus (720x405) in the teacher’s laptop. With this preview the throughput reduces from 1 Gbps to 35 Mbps, so the recourses that he needs reduces at 3,52 %. The teacher can see this preview in his laptop with a Wi-Fi connection at real time. Fig 6.1 The preview from HD flow in the teacher’s laptop
VIDEO ADAPTATION APPLICATIONS 55 6.2. Producer’s room in a TV program A TV program is going to emit its programming in HD resolution. Many HD cameras are distributed for the TV set and those cameras are connected by a Gigabit Ethernet connection to the producer’s room. The producer receives all HD flows and he need a scenario where he can see all HD flows to choose which one is going to be transmitted. Our preview allows him to see many HD flows reduced to another resolution in the display at the same time. UltraGrid has a display module to paint the different flows in a display scenario that uses all TFT displays to paint the flows. This module is named SAGE [21]. With this module is achieved to increase the resolution according to the number of TFT displays and its resolutions. Fig 6.2 4800x2400 scenario to visualize many previews Fig 6.3 Three previews from HD flows painted in the 4800x2400 scenario
56 Adaptive media content architecture regarding users capabilities One scenario could be the showed in the previous images, where six TFT displays are added and form a 4800x2400 scenario. With this configuration, if all the previews change resolution to PALplus resolution, is achieved to paint in this scenario until 30 previews as shown in the next formulas: Horizontal =4800 720 =6,66 (6.1) Vertical =2400 405 =5,93 (6.2) Number of previews =65=30 previews (6.3)
ENVIRONMENTAL IMPACT 57 CHAPTER 7. ENVIRONMENTAL IMPACT The high quality content repositories are growing and are being in more scientific community fields. These repositories allow some people to access to important data, but to access to this data there was needed to have an amount of recourses that not many people have, there was needed to spent so much time to download this data and there was needed a display able to paint this high quality content. So, with the video adaptation techniques is achieved to reduce the recourses needed, the time spent to download the data is null due to the adaptation is done at real time and the display could be an ordinary laptop with a Wi-Fi connection. So, the techniques presented in this project contribute to save time and money.
58 Adaptive media content architecture regarding users capabilities CHAPTER 8. CONCLUSIONS AND FUTURE WORKS 8.1. Conclusions Has been proved that the PSNR computation and the drawn the error tool developed within this project, presented in the chapter 3 and used in many chapters, are two useful tools to determinate the quality of the compressions. In the chapter 4 has been described three different types of compression to reduce the bandwidth. Then, the tables of the different combinations of this compressions shows that the bandwidth could be adapted to the user capabilities from the original throughput of 995,33 Mbps until 34,99 Mbps, that is the 3,52 % of the original throughput, keeping 30 frames per second and keeping for good quality for the project objectives; and could be adapted to 11,66 Mbps if the frame rate could be reduced to 10 fps, that is the 1,17 % of the original throughput. As seen in the 4.2 section, the DXT compression achieves a good objective and subjective quality reducing by a quarter the bandwidth, so the original 1 Gbps is converted to 250 Mbps in 2K resolution. But the compression could be applied to any resolution, so it allows compressing the K and the PALplus images reducing still more the bandwidth. In the chapter 5, the compressions purposed in this project have been compared with two professional image editors (Photoshop and Paint). As a result of this comparison, has been validated that the quality of the compressions purposed are equal or better than to quality of the professional software. The reason of the high quality achieved is due to the compressions has been customized specifically to the case to convert from 2K to K or PALplus, not as in these programs. Then were compared DXT and DV compressions applied to the same PALplus image. The result of the comparison is that the DXT compression has an enough similar quality value to DV compression, but the throughput is about 60 % higher. In terms of latency, DV compression adds 2/3 seconds of latency and DXT compression is applied at real time. After that, two different examples of applications of the video adaptation purposed in this project have been presented. In the first example is showed that the teacher achieves to solve all the problems that he had to know if the video that he will download is that he wants (recourses, time and display). He could see the preview in his laptop with a Wi-Fi connection at real time. In the second example, there is purposed an scenario where the preview is not used to reduce the bandwidth (there are Gigabit Ethernet connections), but is used to could see all the input flows in a multi display scenario sited in the producer’s room, and the producer could choose which one flow wants to send.
CONCLUSIONS AND FUTURE WORKS 59 8.2. Future works In this project, the DXT compression has been implemented in the UG software in order to decrease the bandwidth of the video. With this compression, working with HD frames, 30 fps are not achieved (works about 20 fps). So, one of the future works could be an study to know what is the reason that 30 fps are not achieved; one of the reason could be the lack of the CPU time needed to do the compression, so if is it the problem, it would be solved by using two CPU for this task. As said in the chapter 4, DXT compression was chosen, although having a low compression ratio (8:1), due to it is the compression that we have more accessible and we have the needed hardware to apply it. But, after this project, the UG software has been ready to accept any other compression to be implemented by an easy form. So, one of the compression algorithms that there be interesting to be implemented is the JPEG 2000 compression that is the most usually used in HDTV and is the recommended compression by the DCI [22] with until 50:1 compression ratio keeping good quality.
66 Adaptive media content architecture regarding users capabilities
ANNEX B 67 ANNEX B. Conversion from 2K to K with HD flows coded by YUV422 #define BYTES_X_HD 1920*2 void adapt_2K_to_K_removing(unsigned char *in){ int i,j,cont=0; int bytes=BYTES_X_HD; while(j<1080){ for(i=0;i<bytes;i=i+8){ *(in+cont) = *(in+(i+j*(bytes))); *(in+cont+1) = *(in+(i+1+j*(bytes))); *(in+cont+2) = *(in+(i+2+j*(bytes))); *(in+cont+3) = *(in+(i+3+j*(bytes))); cont=cont+4; } j=j+2; } } void adapt_2K_to_K_vertical_average(unsigned char *in){ int i, j, cont=0, p1; int bytes=BYTES_X_HD; int p[10]; for(j=0;j<1080;j=j+2){ for(i=0;i<bytes;i=i+8){ p1=i+j*bytes; // the average of the blue chrominance (U) information p[0]=p1; p[1]=p1+bytes; *(in+cont) = average(in, 2, p); p1++; // the average of the luminance (Y) information p[0]=p1; p[1]=p1+2; p[2]=p1+bytes; p[3]=p1+bytes+2; *(in+cont+1) = average(in, 4, p); p1=p1+5; // the average of the red chrominance (V) information p[0]=p1; p[1]=p1+bytes; *(in+cont+2) = average(in, 2, p);
68 Adaptive media content architecture regarding users capabilities p1--; // the average of the luminance (Y) information p[0]=p1; p[1]=p1+2; p[2]=p1+bytes; p[3]=p1+bytes+2; *(in+cont+3) = average(in, 4, p); cont=cont+4; } } } void adapt_2K_to_K_average_from_adjacent_pixel_blocks(unsigned char *in){ int i,j,cont=0,p1; int bytes=BYTES_X_HD; int p[10]; for(j=0;j<1080;j=j+2){ for(i=0;i<bytes;i=i+8){ p1=i+j*bytes; // the average of the blue chrominance (U) information p[0]=p1; p[1]=p1+4; p[2]=p1+bytes; p[3]=p1+4+bytes; *(in+cont)=average(in, 4, p); // the average of the luminance (Y) information p[0]=p1+1; p[1]=p1+3; p[2]=p1+1+bytes; p[3]=p1+3+bytes; *(in+cont+1)=average(in, 4, p); // the average of the red chrominance (V) information p[0]=p1+2; p[1]=p1+6; p[2]=p1+2+bytes; p[3]=p1+6+bytes; *(in+cont+2)=average(in, 4, p); // the average of the luminance (Y) information p[0]=p1+5; p[1]=p1+7; p[2]=p1+5+bytes; p[3]=p1+7+bytes; *(in+cont+3)=average(in, 4, p);
ANNEX B 69 cont=cont+4; } } }
70 Adaptive media content architecture regarding users capabilities
ANNEX C 71 ANNEX C. Conversion from 2K to PAL with HD flows coded by YUV422 #define BYTES_X_HD 1920*2 void adapt_2K_to_PAL_removing(unsigned char *in){ int i,j=0,cont=0,alternation=0,aux=0,p1; int bytes=BYTES_X_HD; while(j<1080){ for(i=0;i<bytes;i=i+16){ p1=i+j*bytes; if(alternation>1) alternation=0; if(alternation!=0) p1=p1+2; *(in+cont) = *(in+p1); *(in+cont+1)= *(in+p1+1); *(in+cont+2)= *(in+p1+6); *(in+cont+3)= *(in+p1+7); *(in+cont+4)= *(in+p1+12); *(in+cont+5)= *(in+p1+13); alternation++; cont=cont+6; } if(aux==14){ j++; aux=0; } else{ j=j+2; aux=aux+2; } } }
72 Adaptive media content architecture regarding users capabilities
ANNEX D 73 ANNEX D. Conversion from 2K to PALplus with HD flows coded by YUV422 #define BYTES_X_HD 1920*2 void adapt_2K_to_PALplus_removing(unsigned char *in){ int i,j=0,cont=0,alternation=0,aux=0,p1; int bytes=BYTES_X_HD; while(j<1080){ for(i=0;i<bytes;i=i+16){ p1=i+j*bytes; if(alternation>1) alternation=0; if(alternation!=0) p1=p1+2; *(in+cont) = *(in+p1); *(in+cont+1)= *(in+p1+1); *(in+cont+2)= *(in+p1+6); *(in+cont+3)= *(in+p1+7); *(in+cont+4)= *(in+p1+12); *(in+cont+5)= *(in+p1+13); alternation++; cont=cont+6; } if(aux==2){ j=j+2; aux=0; } else{ j=j+3; aux++; } } } void adapt_2K_to_PALplus_average(unsigned char *in){ int i,j=0,cont=0,alternation=0,aux=0,p1; int bytes=BYTES_X_HD; int p[10]; while(j<1080){
74 Adaptive media content architecture regarding users capabilities for(i=0;i<bytes;i=i+32){ p1=i+j*bytes; if(alternation==2){ p[0]=p1; p[1]=p1+4; p[2]=p1+bytes; p[3]=p1+4+bytes; *(in+cont) = average(in, 4, p); p[0]=p1+1; p[1]=p1+3; p[2]=p1+5; p[3]=p1+1+bytes; p[4]=p1+3+bytes; p[5]=p1+5+bytes; *(in+cont+1) = average(in, 6, p); p[0]=p1+6; p[1]=p1+6+bytes; *(in+cont+2) = average(in, 2, p); p[0]=p1+7; p[1]=p1+9; p[2]=p1+11; p[3]=p1+7+bytes; p[4]=p1+9+bytes; p[5]=p1+11+bytes; *(in+cont+3) = average(in, 6, p); p[0]=p1+8; p[1]=p1+12; p[2]=p1+8+bytes; p[3]=p1+12+bytes; *(in+cont+4) = average(in, 4, p); p[0]=p1+13; p[1]=p1+15; p[2]=p1+13+bytes; p[3]=p1+15+bytes; *(in+cont+5) = average(in, 4, p); p[0]=p1+18; p[1]=p1+22; p[2]=p1+18+bytes; p[3]=p1+22+bytes; *(in+cont+6) = average(in, 4, p); p[0]=p1+17; p[1]=p1+19; p[2]=p1+21; p[3]=p1+17+bytes;
ANNEX D 75 p[4]=p1+19+bytes; p[5]=p1+21+bytes; *(in+cont+7) = average(in, 6, p); p[0]=p1+24; p[1]=p1+24+bytes; *(in+cont+8) = average(in, 2, p); p[0]=p1+23; p[1]=p1+25; p[2]=p1+27; p[3]=p1+23+bytes; p[4]=p1+25+bytes; p[5]=p1+27+bytes; *(in+cont+9) = average(in, 6, p); p[0]=p1+26; p[1]=p1+30; p[2]=p1+26+bytes; p[3]=p1+30+bytes; *(in+cont+10) = average(in, 4, p); p[0]=p1+29; p[1]=p1+31; p[2]=p1+29+bytes; p[3]=p1+31+bytes; *(in+cont+11) = average(in, 4, p); } else{ p[0]=p1; p[1]=p1+4; p[2]=p1+bytes; p[3]=p1+4+bytes; p[4]=p1+bytes*2; p[5]=p1+4+bytes*2; *(in+cont) = average(in, 6, p); p[0]=p1+1; p[1]=p1+3; p[2]=p1+5; p[3]=p1+1+bytes; p[4]=p1+3+bytes; p[5]=p1+5+bytes; p[6]=p1+1+bytes*2; p[7]=p1+3+bytes*2; p[8]=p1+5+bytes*2; *(in+cont+1) = average(in, 9, p); p[0]=p1+6; p[1]=p1+6+bytes; p[2]=p1+6+bytes*2; *(in+cont+2) = average(in, 3, p);
82 Adaptive media content architecture regarding users capabilities if((aux==0)||(aux==1)){ // the average of the Red (R) information p[0]=p1; p[1]=p1+4; p[2]=p1+8; p[3]=p1+bytes; p[4]=p1+bytes+4; p[5]=p1+bytes+8; p[6]=p1+bytes*2; p[7]=p1+bytes*2+4; p[8]=p1+bytes*2+8; *(in+cont) = average(in, 9, p); // the average of the Green (G) information p[0]=p1+1; p[1]=p1+4+1; p[2]=p1+8+1; p[3]=p1+bytes+1; p[4]=p1+bytes+4+1; p[5]=p1+bytes+8+1; p[6]=p1+bytes*2+1; p[7]=p1+bytes*2+4+1; p[8]=p1+bytes*2+8+1; *(in+cont+1) = average(in, 9, p); // the average of the Blue (B) information p[0]=p1+2; p[1]=p1+4+2; p[2]=p1+8+2; p[3]=p1+bytes+2; p[4]=p1+bytes+4+2; p[5]=p1+bytes+8+2; p[6]=p1+bytes*2+2; p[7]=p1+bytes*2+4+2; p[8]=p1+bytes*2+8+2; *(in+cont+2) = average(in, 9, p); // the average of the Alpha (A) information p[0]=p1+3; p[1]=p1+4+3; p[2]=p1+8+3; p[3]=p1+bytes+3; p[4]=p1+bytes+4+3; p[5]=p1+bytes+8+3; p[6]=p1+bytes*2+3; p[7]=p1+bytes*2+4+3; p[8]=p1+bytes*2+8+3; *(in+cont+3) = average(in, 9, p); p1=p1+12;
ANNEX F 83 // the average of the Red (R) information p[0]=p1; p[1]=p1+4; p[2]=p1+8; p[3]=p1+bytes; p[4]=p1+bytes+4; p[5]=p1+bytes+8; p[6]=p1+bytes*2; p[7]=p1+bytes*2+4; p[8]=p1+bytes*2+8; *(in+cont+4) = average(in, 9, p); // the average of the Green (G) information p[0]=p1+1; p[1]=p1+4+1; p[2]=p1+8+1; p[3]=p1+bytes+1; p[4]=p1+bytes+4+1; p[5]=p1+bytes+8+1; p[6]=p1+bytes*2+1; p[7]=p1+bytes*2+4+1; p[8]=p1+bytes*2+8+1; *(in+cont+5) = average(in, 9, p); // the average of the Blue (B) information p[0]=p1+2; p[1]=p1+4+2; p[2]=p1+8+2; p[3]=p1+bytes+2; p[4]=p1+bytes+4+2; p[5]=p1+bytes+8+2; p[6]=p1+bytes*2+2; p[7]=p1+bytes*2+4+2; p[8]=p1+bytes*2+8+2; *(in+cont+6) = average(in, 9, p); // the average of the Alpha (A) information p[ 0]=p1+3; p[1]=p1+4+3; p[2]=p1+8+3; p[3]=p1+bytes+3; p[4]=p1+bytes+4+3; p[5]=p1+bytes+8+3; p[6]=p1+bytes*2+3; p[7]=p1+bytes*2+4+3; p[8]=p1+bytes*2+8+3; *(in+cont+7) = average(in, 9, p); p1=p1+12; // the average of the Red (R) information p[0]=p1;
84 Adaptive media content architecture regarding users capabilities p[1]=p1+4; p[2]=p1+bytes; p[3]=p1+bytes+4; p[4]=p1+bytes*2; p[5]=p1+bytes*2+4; *(in+cont+8) = average(in, 6, p); // the average of the Green (G) information p[0]=p1+1; p[1]=p1+4+1; p[2]=p1+bytes+1; p[3]=p1+bytes+4+1; p[4]=p1+bytes*2+1; p[5]=p1+bytes*2+4+1; *(in+cont+9) = average(in, 6, p); // the average of the Blue (B) information p[0]=p1+2; p[1]=p1+4+2; p[2]=p1+bytes+2; p[ 3]=p1+bytes+4+2; p[4]=p1+bytes*2+2; p[5]=p1+bytes*2+4+2; *(in+cont+10) = average(in, 6, p); // the average of the Alpha (A) information p[0]=p1+3; p[1]=p1+4+3; p[2]=p1+bytes+3; p[3]=p1+bytes+4+3; p[4]=p1+bytes*2+3; p[5]=p1+bytes*2+4+3; *(in+cont+11) = average(in, 6, p); cont=cont+12; } if(aux==2){ // the average of the Red (R) information p[0]=p1; p[1]=p1+4; p[2]=p1+8; p[3]=p1+bytes; p[4]=p1+bytes+4; p[5]=p1+bytes+8; *(in+cont) = average(in, 6, p); // the average of the Green (G) information p[0]=p1+1; p[1]=p1+4+1; p[2]=p1+8+1; p[3]=p1+bytes+1;
ANNEX F 85 p[4]=p1+bytes+4+1; p[5]=p1+bytes+8+1; *(in+cont+1) = average(in, 6, p); // the average of the Blue (B) information p[0]=p1+2; p[1]=p1+4+2; p[2]=p1+8+2; p[3]=p1+bytes+2; p[4]=p1+bytes+4+2; p[5]=p1+bytes+8+2; *(in+cont+2) = average(in, 6, p); // the average of the Alpha (A) information p[0]=p1+3; p[1]=p1+4+3; p[2]=p1+8+3; p[3]=p1+bytes+3; p[4]=p1+bytes+4+3; p[5]=p1+bytes+8+3; *(in+cont+3) = average(in, 6, p); p1=p1+12; // the average of the Red (R) information p[0]=p1; p[1]=p1+4; p[2]=p1+8; p[3]=p1+bytes; p[4]=p1+bytes+4; p[5]=p1+bytes+8; *(in+cont+4) = average(in, 6, p); // the average of the Green (G) information p[0]=p1+1; p[1]=p1+4+1; p[2]=p1+8+1; p[3]=p1+bytes+1; p[4]=p1+bytes+4+1; p[5]=p1+bytes+8+1; *(in+cont+5) = average(in, 6, p); // the average of the Blue (B) information p[0]=p1+2; p[1]=p1+4+2; p[2]=p1+8+2; p[3]=p1+bytes+2; p[4]=p1+bytes+4+2; p[5]=p1+bytes+8+2; *(in+cont+6) = average(in, 6, p); // the average of the Alpha (A) information
86 Adaptive media content architecture regarding users capabilities p[0]=p1+3; p[1]=p1+4+3; p[2]=p1+8+3; p[3]=p1+bytes+3; p[4]=p1+bytes+4+3; p[5]=p1+bytes+8+3; *(in+cont+7) = average(in, 6, p); p1=p1+12; // the average of the Red (R) information p[0]=p1; p[1]=p1+4; p[2]=p1+bytes; p[3]=p1+bytes+4; *(in+cont+8) = average(in, 4, p); // the average of the Green (G) information p[0]=p1+1; p[1]=p1+4+1; p[2]=p1+bytes+1; p[3]=p1+bytes+4+1; *(in+cont+9) = average(in, 4, p); // the average of the Blue (B) information p[0]=p1+2; p[1]=p1+4+2; p[2]=p1+bytes+2; p[3]=p1+bytes+4+2; *(in+cont+10) = average(in, 4, p); // the average of the Alpha (A) information p[0]=p1+3; p[1]=p1+4+3; p[2]=p1+bytes+3; p[3]=p1+bytes+4+3; *(in+cont+11) = average(in, 4, p); cont=cont+12; } } if(aux==2){ j=j+2; aux=0; } else{ j=j+3; aux++; } } }