A Brief Introduction to Digital Video

转自http://www.spacewire.co.uk/video_standard.html

This page provides a brief introduction to the BT656 (4:2:2) YCbCr Standard Definition 8-bit Digital Video format. By no means does it describe the full video standard in detail, it mealy introduces the subject matter from an implementation perspective.



Frames
A full frame of interlaced video consists of two almost identical fields. The first field contains all the odd video lines and the second field contains all the even video lines.



Fields
A field is made up of three distinct regions, first blanking period, active video and second blanking period. The difference between the first field and the second, is merely in the number lines during the first blanking period, the first field having one less than the second.

A complete NTSC/PAL video frame (both fields) is shown below: -

LinesField / VBlkLine
Description
PALNTSCFV
2219'0''1'Field 1 - First Vertical Blanking (Top)
288240'0''0'Field 1 - Active Video
23'0''1'Field 1 - Second Vertical Blanking (Bottom)
2320'1''1'Field 2 - First Vertical Blanking (Top)
288240'1''0'Field 2 - Active Video
23'1''1'Field 2 - Second Vertical Blanking (Bottom)
625525 

There are two very important values to remember here, these being F (Field Number) and V (Vertical Blanking). These values control the vertical position of a line.

A logic zero on F states that a line belongs in Field 1, likewise a logic one on F states that a line belongs in Field 2.

A logic zero on V states that a line is part of the Active Video, whereas a logic one on V states that a line is part of the Vertical Blanking.



Lines
Lines consist of four parts, EAV Code, Blanking Video, SAV Code and Active Video. These are shown below: -

EAV CodeBlanking VideoSAV CodeActive Video
25500EAVCbYCrY25500SAVCbYCrY
4 Bytes280 (268) Bytes4 Bytes1440 Bytes

The EAV (End Active Video) and SAV (Start Active Video) Codes are made up of four bytes. The first three bytes provide the video synchronization and the last one byte provides the line coding.

What has not been discussed so far is H, the Horizontal Blanking value, this is a logic one during the EAV Code, Blanking Video and SAV Code, then becomes a logic zero for the duration of Active Video.

Note: The above description of Horizontal Blanking indicates that the H value of SAV is a logic one, this however is not the case. The H value of SAV should be a logic zero, even though the H value itself will be a logic one at this point. Care should be taken when implementing this logic!!

Both the EAV and SAV bytes are constructed in exactly the same way, as shown below: -

Bit:76543210
Value:'1'FVHV xor HF xor HF xor VF xor V xor H

The Exclusive-OR components of these bytes can be used to detect and correct errors in the F, V and H values. Both one and two bit errors can be corrected by these components.

The Blanking Video period of a line consists of 280 bytes (PAL) or 268 bytes (NTSC) and the Active Video period of a line consists of 1440 bytes (PAL & NTSC). What these bytes represent is a repeated sequence of, Cb, Y, Cr, Y, where: -

Y=Brightness (Nominal Range 16-235)
Cb=Blue Chrominance (Nominal Range 16-240)
Cr=Red Chrominance (Nominal Range 16-240)

The YCbCr colour space is very different from the RGB colour space, but sometimes it is useful to convert between the two. The formulae for these conversions are given below: -

Y=16+0.257R+0.504G+0.098B
Cb=128-0.148R-0.291G+0.439B
Cr=128+0.439R-0.368G-0.071B

R=1.164(Y - 16)+1.596(Cr - 128) 
G=1.164(Y - 16)-0.813(Cr - 128)-0.391(Cb - 128)
B=1.164(Y - 16)+2.018(Cb - 128) 

These formulae convert R(0-255), G(0-255), B(0-255) into Y(16-235), Cb(16-240), Cr(16-240) and visa-versa.

For every two Y values there is only one Cb and Cr value, this means that care must be taken when converting from RGB. Many sampling techniques exist for performing this conversion, the simplest two are based on converting one or two pixels at a time, these are given below: -



One Pixel Interleave
The above conversion formulae are used to convert one RGB pixel at a time, using only the Blue Chrominance for the even pixels and the Red Chrominance for the odd pixels: -

Pixel 1:Y=16+0.257R0+0.504G0+0.098B0
 Cb=128-0.148R0-0.291G0+0.439B0
 
Pixel 2:Y=16+0.257R1+0.504G1+0.098B1
 Cr=128+0.439R1-0.368G1-0.071B1

The final result: (R 0, G 0, B 0), (R 1, G 1, B 1) to (Cb 0, Y 0), (Cr 1, Y 1), etc.



Two Pixel Average
The above conversion formulae are used to convert two RGB pixels at a time, the Blue and Red Chrominance values are then averaged to obtain the final chrominance values: -

Pixel 1:Y0=16+0.257R0+0.504G0+0.098B0
 Cb0=128-0.148R0-0.291G0+0.439B0
 Cr0=128+0.439R0-0.368G0-0.071B0
 
Pixel 2:Y1=16+0.257R1+0.504G1+0.098B1
 Cb1=128-0.148R1-0.291G1+0.439B1
 Cr1=128+0.439R1-0.368G1-0.071B1
 
Average:Cb01=(Cb0 + Cb1) / 2
 Cr01=(Cr0 + Cr1) / 2

The final result: (R 0, G 0, B 0), (R 1, G 1, B 1) to (Cb 01, Y 0, Cr 01, Y 1), etc.



The Complete Picture
The simplest video screen to create is a flood filled screen of one colour, for this the Y, Cb and Cr values need to be calculated for that colour, this is shown below: -

For a bright blue colour the RGB values are, Red=0, Green=0 and Blue=255. By using the above conversion formulae the YCbCr values can be obtained: -

Y=16+0.257(0)+0.504(0)+0.098(255)=41
Cb=128-0.148(0)-0.291(0)+0.439(255)=240
Cr=128+0.439(0)-0.368(0)-0.071(255)=110

It is customary in video to produce black pixels during the blanking periods, when auxiliary data such has sound and teletext are not being transmitted. Again by using the conversion formulae the YCbCr values can be obtained: -

Y=16+0.257(0)+0.504(0)+0.098(0)=16
Cb=128-0.148(0)-0.291(0)+0.439(0)=128
Cr=128+0.439(0)-0.368(0)-0.071(0)=128

Using the Frame, Field and Line descriptions above, a complete screen of blue video can be built up. An example of this is shown below for a PAL screen (NTSC values are shown in parenthesis): -

Field 1 - First Vertical Blanking (Top) - Repeat for 22 (19) lines
EAV CodeBlanking VideoSAV CodeActive Video
255001821281612816255001711281612816
Repeat 1 (1) timeRepeat 70 (67) timesRepeat 1 (1) timeRepeat 360 (360) times

Field 1 - Active Video - Repeat for 288 (240) lines
EAV CodeBlanking VideoSAV CodeActive Video
255001571281612816255001282404111041
Repeat 1 (1) timeRepeat 70 (67) timesRepeat 1 (1) timeRepeat 360 (360) times

Field 1 - Second Vertical Blanking (Bottom) - Repeat for 2 (3) lines
EAV CodeBlanking VideoSAV CodeActive Video
255001821281612816255001711281612816
Repeat 1 (1) timeRepeat 70 (67) timesRepeat 1 (1) timeRepeat 360 (360) times

Field 2 - First Vertical Blanking (Top) - Repeat for 23 (20) lines
EAV CodeBlanking VideoSAV CodeActive Video
255002411281612816255002361281612816
Repeat 1 (1) timeRepeat 70 (67) timesRepeat 1 (1) timeRepeat 360 (360) times

Field 2 - Active Video - Repeat for 288 (240) lines
EAV CodeBlanking VideoSAV CodeActive Video
255002181281612816255001992404111041
Repeat 1 (1) timeRepeat 70 (67) timesRepeat 1 (1) timeRepeat 360 (360) times

Field 2 - Second Vertical Blanking (Bottom) - Repeat for 2 (3) lines
EAV CodeBlanking VideoSAV CodeActive Video
255002411281612816255002361281612816
Repeat 1 (1) timeRepeat 70 (67) timesRepeat 1 (1) timeRepeat 360 (360) times



Colour Bars
When developing video solutions the first port of call is usually the colour bar test pattern. This is constructed from equal width vertical stripes of white, yellow, cyan, green, magenta, red, blue and black. Converting these colours from RGB to YCbCr is a very simple process of using the above formulae, the end results are shown below: -

 RGB Colour BarsYCbCr Colour Bars
RGBYCbCr
White255255255235128128
Yellow255255021016146
Cyan025525517016616
Green025501455434
Magenta2550255107202222
Red255008290240
Blue0025541240110
Black00016128128

To create a colour bar test screen, a simple substitution is required in the complete picture example. This is performed on the Field 1 and Field 2 Active Video lines, during the Active Video portion of the line. Instead of the repeated sequence of 240, 41, 110, 41 the following sequence is used: -

WhiteYellowCyanGreen
12823512823516210146210166170161705414534145
Repeat 45 timesRepeat 45 timesRepeat 45 timesRepeat 45 times

MagentaRedBlueBlack
20210722210790822408224041110411281612816
Repeat 45 timesRepeat 45 timesRepeat 45 timesRepeat 45 times


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值