You are on page 1of 10

BAI 5- NEN JPEG VA NEN MPEG

phn trn chng ta tm hiu mt s php bin i ton hc l c s cho cc k thut nn nh, s dng nhiu trong nn d liu video. Phn ny chng ta xem xt mt s k thut nn nh c s dng ph bin hin nay I K THUT NN NH JPEG JPEG - vit tt cua nhom t Joint Photographic Experts Group. No c CCITT(International Telegraph and Telephone Consultative Committee) cng nhn va a c cng nhn la chun ISO nm 1991. No co cac c im sau: 1. Ty l nen cao 2. s dung nhiu tham s hiu chinh cac ti l nen, cht lng nen 3. Rt tt cho cac loai anh en trng va cac anh co tone thay i lin tuc 4. Khng qua phc tap cho ca phn mm va phn cng. Qua trinh nen JPEG co th tom tt gm cac bc sau : 1- Chuyn i khng gian mu - Chuyn anh t khng gian mau RGB sang khng gian mau ( brightness, Hue, Saturation). Ly do mt ngi nhn ra nhng thay i nho cua thanh phn luminance nhng khng nhy cam vi s thanh i cua thanh phn chrominance, ngi ta da vao iu nay bo bt d liu cua thanh phn chrominance . Vic chuyn i khng gian mau trong Jpeg va Mpeg c thc hin theo cng thc sau : s dung ba tham s Y, Cb, Cr ; Y ng vi brightness ( sng, chi) Cb,Cr la hai thanh phn ng vi Hue (sc mau) va Saturation( m nhat). vi y thuc khoang [16, 235], khi o vic chuyn khng gian mau c thc hin theo cng thc sau: Y = (77/256)R + (150/256)G + (29/256)B, Cb = (44/256)R (87/256)G + (131/256)B + 128, Cr = (131/256)R (110/256)G (21/256)B + 128; Phep chuyn ngc t YCbCr theo cng thc : R=Y+1.371(Cr 128) ; G=Y 0.698(Cr 128) 0.336(Cb 128) ; B=Y+1.732(Cb 128). 2- Gim phn gii Sau khi chuyn i khng gian mau , ngi ta gim phn giai cua anh gc, lam giam d liu cua thanh phn Hue v Saturation. Vic lam nay co th theo cac ti l khac nhau. vi du phn giai co th thay i theo ti l 2:1 gia hang va ct 3. Chia nh thnh cc khi 8 x8

Anh mau c chia thanh cac khi 8 x8 , coi khi nay la mt n vi d liu. cac n vi d liu c nen ring bit. Trong trng hp kich thc anh khng la bi cua 8, ta thm hang vao hng cui anh, thm ct vao ct cui bn phai. 4- Thc hin bin i cosin trn s zizag S dung phep bin i cosin bin i trn khi 8 x8 ( n vi d liu ). Phep bin i dc thc hin trn mang 8 x 8 hay trn n vi d liu anh theo cng thc sau :

Khi giai nen s dung phep bin i cosin ngc theo cng thc

5.- Lng hoa : Sau khi bin i cosin trn cc n vi d liu ta nhn c day co 64 thanh phn , cac thanh phn nay goi la cac h s lng t hay h s QC ( quantization coe cient -QC) .Cac h s QC c lam tron v dang s nguyn. Sau o ngi s dung nhiu khi thut khac nhau giam kich thc d liu cua cac thanh phn nay. Chng han ky thut lu gi s sai khac tng i cua cac h s QC hoc s dung cac bang lng hoa mau a c khuyn cao bi nhm Jpeg. 6- S dng k thut nn S dung ky thut nen RLE hoc ma Hufman, ma s hoc ma cac h s QC. Ma s hoc c coi la ky thut ma ti u.

II- Ho chun nen MPEG


MPEG -vit tt cua Moving Pictures Experts Group , no la tn goi chi nhom chuyn gia thc hin d an nen d liu media. D an nay c bt u t nm1988. Kt qua d an a c tha nhn la chun ISO (International Standardization Organization) va chun IEC (International Electrotechnical Committee). Thc cht Mpeg la ky thut nen d liu video, no c s dung nen anh va m thanh s v ng b hai loai d liu nay. co cai nhin h thng v ho chun Mpeg , chung ta hay xem xet cac phin ban cua ho chun Mpeg. Cho n nay a co cac phin ban sau : -Mpeg-1 :phat trin chun nen d liu multimedia (video, audio) da trn muc tiu la tng tac vi CD va thit bi digital audio broadcasting. Chun nay a rt thanh cng trong linh vc thng mai trong thi gian qua. n nay ngi ta vn dung Mpeg-1 cho d liu video va c kt hp vi ky thut nen audio MP3. - Mpeg -2 c danh chu yu muc tiu truyn hinh s ( digital television). Cac ky thut cua no ap ng cho vic nen ci nen va ng b d liu video trong linh vc truyn hinh. - Mpeg-3 : vi muc tiu nen d liu multimedia tng tac vi cac ia quang co mt ghi cao nh HDVD ( High-Definition/Density DVD ). Nhng kt qua thu c khng khac bit nhiu vi Mpeg-2 , nn ngi ta bo phin ban nay.

- Mpeg-4 vi muc tiu nhm vao nen, ci nen d liu multimedia co tc thp , c vai nghin bit trn giy. No nhm vao cac thit bi x ly multimedia nho, thit bi cm tay nh video telephones , mobile phone , thit bi di chuyn nhanh (cac thit bi multimedia t trn xe..) nen , ci nen va truyn nhanh cac oan video ngn. Mt c im quan trong cua Mpeg-4 la ngi ta a a quan im x ly object vao trong qua trinh x ly d liu nh o no t c nn tang cho cac linh vc lin quan phat trin trong tng lai. Cac chun cua Mpeg co vai tro rt quyt inh n tc truy cp d liu. Chun Mpeg-1 co c 1.5 Mbit/s . Mpeg-2 co tc thp nht 10 Mbit/s. Mpeg -4 nhm vao cac thit bi nho , thit bi cm tay nn tc truy cp chi at ti a 64 Kbit/s . hiu nguyn ly lam vic cua ho chun Mpeg chung ta se xem xet ky thut nen Mpeg-1.

1- Chun Mpeg-1
Mpeg-1 c thc cht cho d liu video . tai liu cua chun c m ta trong tai liu IS1172-2.cua t chc ISO. Di y chung ta se tim hiu mt s ky thut s dung trong Mpeg-1 a - Ty l nen video cua Mpeg-1 co th s dung d liu video, Mpeg-1 cn phai at ti l nen bao nhiu ? d hiu ta xet vi du sau : - Gia s anh video co phn giai 360288 - su cua anh (depth) 24bit/pixel; - Tc lam ti anh (refresh rate) 24 frame/s - d liu m thanh : tc ly mu 44 KHz ; phn giai 16bit/sample; mode stereo. Khi o tc oc phn d liu anh la :3602882424 = 59,719,680 bits/s; Tc oc d liu m thanh : 244,00016 = 1,408,000 bits/s.

Nh vy oc ca m va hinh cn tc khoang 61.1 Mbit/s. Nu oc vi tc 1,5 Mbit/s thi h s nen cn at ln hn 40 ln. y chung ta cha tinh n thi gian giai nen. iu nay giai thich vi sao Mpeg-1 phai co ti l nen cao, tc giai nen nhanh. Lu rng tc c vt l ca cc a CD l 150 Kbps y l tc c bn , k hiu l x, b- Mpeg-1 nen d liu nh ky thut chuyn i khng gian mau Mi anh trong day anh video c chuyn t khng gian mau RGB sang khng gian mau Y, Cb, Cr trong o Y ng vi thanh phn aluminance , Cb, Cr ng vi Chrominance hai thanh phn nay tng ng hue (sc mau) va saturate ( m nhat). Da vao c im mt ngi khng nhay cam vi s thay i cua Cb, Cr , Mpeg-1 ly phn giai cua Cb, Cr bng na phn giai cua Y.

c- Mpeg-1 nen d liu va tao thanh cac goi (packet) Mi goi c bt u bng code gm 32 bit, tip theo la header va kt thuc goi bng ma endcode 32 bit. gia header va end ode co cha mt s goi.Mi goi cha d liu nen hoc audio hoc video. Kich thc cua mi goi c xac inh trc bi b ma Mpeg (MPEG encoder theo yu cu lu tr hoc thit bi truyn i) , iu nay giai thich vi sao mt packet khng cn y u cac anh video, no co th la phn nao cua audio, phn nao o cua anh video.Hinh H15 di y m ta cu truc d liu nen cua Mpeg-1

d - Mpeg-1 giai nen audio va anh ng ring bit B giai ma Mpeg-1 nhm khi phuc lai d liu video , no gm 3 lp (layer). Lp giai ma anh video, lp giai ma audio va lp data system. Lp data system co nhim vu oc va phn tich d liu trong phn header cua cac goi , cac ng dn dn n cac goi khac, ng b d liu a giai nen cac buffer.

e - Mpeg-1 s dung 3 loai anh I ,P,B nen - nh I (Intra frame, key frame) c th coi l nh gc, vi nh ny khi gii m n khng cn ly thng tin t nh khc; - Anhr P (predicted picture ) l nh khi gii nn n phi s dng thng tin t cc nh trc n, thng n l nn ca nh I. - nh B (Bi directionaly frame ) l nh m khi gii nn n phi dng c nh ng trc v nh sau n. nh B l nh c t l nn cao nht. v d Hnh H1

Hnh H1

Hnh

H2

T khi nim nh I,B,P chng ta d thy rng trt t cc nh trn a CD khc vi trt t xut hin ca cc nh . Trong hnh H2 , dy s m ngang l th t nh trn a CD, ct s bn phi l th th nh khi play. Khi nen Mpeg s dung ba kiu anh I,P, B . Cac anh nay c xp thanh tng nhom, cac nhom co th t chc thanh loai nhom ong hoc nhom m (open group, closed group).Nhom ong la nhom ma khi khi phuc anh no chi s dung cac anh trong nhom, nhom m la nhom co th s dung anh ngoai nhom khi phuc lai anh. Cac anh I,P,B u vao c sp xp theo mt trt t nao o, sau khi giai nen ta c day anh mi hin thi. Noi chung trt t hin thi khac vi trt t vao. Mt vung cua anh ang xet khi giai ma co th phai dung n cac anh trc, anh sau trong nhom hoc ngoai nhom. f - Mpeg-1 s dung phep bin i cosin trong qua trinh nen Mi anh c Mpeg-1 chia thanh cac khi c ban goi la macroblock . Khi c ban co kich thc 16 x16, khi nay co cung thanh phn luminance. Mi macroblock lai c chia thanh 4 khi 8 x 8 (block) va hai khi 8 x 8 cho thanh phn chrominance. Cc khi nay se c bin i cosin lng hoa va ma hoa.

Qua trinh lng hoa va ma hoa cua Mpeg -1 tng t nh Jpeg . Khi ma hoa Mpeg va Jpeg khac nhau bang ma va cach lam trong v s nguyn . Mpeg s dung cach lam tron v s nguyn gn nht, g - Mpeg-1 t chc anh thanh cac slice Mi anh trong Mpeg c t chc thanh cac slice, mi slice gm mt s macroblock lin k nhau co cung mc xam, tiu chun nay ap dung cho cac thanh phn luminance. Khai nim slice tng ng vi mt vung rng cua anh gm cac macroblock co cung mc xam.

2 - Chun MPEG-4
MPEG-4 la chun mi cho d liu audiovisual data.Tuy nhin nen video va audio vn la c im ni tri cua Mpeg -4 .Phn nay m ta nhng net chinh v MPeg4. Mpeg-4 c bt u t 5/1991.Nm 1999 cng b chun phin ban u tin.Nm 2003 Mpeg-4 ISO va IEC cng nhn quc t . Tai liu chun mang ma s ISO/IEC 14496. Di y la mt s c trng quan trong cua Mpeg-4 : a- Co cac cng cu (Tools) c ban truy cp d liu multimedia. Nh cac cng cu nay, ngi ta co th indexing, linking , quering,browsing,delivering file, deleting file... b- Co th kt ni, thay i va Edit cac bitstream trn cac file nen ma khng cn ci nen. c- Cho phep lai ghep d liu t nhin va nhn tao. cac canh quay t camera , cung vi text, cac canh nhn tao co th tng hp thanh mt canh mi va nen chung vi nhau. d- Cho phep truy cp trc tip hay con goi la truy cp random vao d liu iu nay rt quan trong , lam cho qua trinh x ly hiu qua.

e. Nen hiu qua ; do yu cu cua loai thit bi ma mpeg-4 phuc vu cho nn no oi hoi ti l nen phai cao, no phai dung hoa cac yu t cht lng, tc , dung tich nh... f. Cung luc co th lam vic vi nhiu dong d liu ( data streams) g. Rt manh trong x ly li . Do no phai phuc vu trong iu kin truyn thng vi du nhiu, ng truyn bi s c.....tt ca u co th sinh ra li. h. Co kha nng iu chinh tt .Cac dong d liu co th cac phn giai khac nhau, tc khac nhau khi giai nen mpeg-4 cho phep a v phn giai thp, tc thp. S CA B M HO V GII M DNG MPEG-2 S b m ho v gii m MPEG 2 c trnh by trn hnh 2. M ho MPEG-2 Qu trnh m ho cho P pictures v B pictures c gii thch nh sau: D liu t cc khi nh (macroblocks) cn c m ho s c a n c b tr (Subtractor) v b on chuyn ng (Motion Estimator). B on chuyn ng s so snh cc khi nh mi c a vo ny vi cc khi nh c a vo trc v c lu li nh l cc nh dng tham kho (Reference Picture). Kt qu l b on chuyn ng s tm ra cc khi nh trong nh tham kho gn ging nht vi khi nh mi ny. B on chuyn ng sau s tnh ton vector chuyn ng (Motion Vector), vector ny s c trng cho s dch chuyn theo c hai chiu dc v ngang ca khi nh mi cn m ho so vi nh tham kho. Chng ta lu rng vector chuyn ng c phn gii bng mt na do thc hin qut xen k. B on chuyn ng cng ng thi gi cc khi nh tham kho ny m chng thng c gi l cc khi tin on (Predicted macroblock) ti b tr tr vi khi nh mi cn m ho (thc hin tr tng im nh tng ng tc l Pixel by pixel). Kt qu l ta s c cc sai s tin on (Error Prediction) hoc tn hiu d, chng s c trng cho s sai khc gia khi nh cn tin on v khi nh thc t cn m ho. Tn hiu d hay sai s tin on ny s c bin i DCT, cc h s nhn c sau bin i DCT s c lng t ho lm gim s lng cc bits cn truyn. Cc h s ny s c a ti b m ho Huffman, ti y s bits c trng cho cc h s tip tc c lm gim i mt cch ng k. D liu t u ra ca m ho Huffman s c kt hp vi vector chuyn ng v cc thng tin khc (thng tin v I, P, B pictures) gi ti b gii m.

Hnh 2. S b m ho v gii m dng MPEG