Допомога у написанні освітніх робіт...
Допоможемо швидко та з гарантією якості!

Реалізація ідеї арифметичного кодування

РефератДопомога в написанніДізнатися вартістьмоєї роботи

Aeaeiaeoaaeueiee ia iax00BA iiox00F0aae ciaoe cia/aiiy iaio iaae ix00B3aenoieiaiai x00B3ioax00F0aaeo, yeee aoa iaeax00F0aeaiee ax00B3ae eiaeoaaeueieea. Iaax00B3oue iaeiiai cia/aiiy, ui eaaeeoue anax00F0aaeeix00B3 iueiai, iaix00F0eeeaae, 0,23 355 aaea aeinoaoiuei. (x00B2iox00B3 /enea — 0,23 354, 0,23 357 oa iaax00B3oue 0,23 354 321 — oex00B3eeii ix00F0eaeaoix00B3). Iaeiae, uia caaax00F0oeoe… Читати ще >

Реалізація ідеї арифметичного кодування (реферат, курсова, диплом, контрольна)

Iaoex00B3iiaeueiee oix00B3aax00F0neoao.

«EEx00AAAI-IIAEEssINUeEA AEAAeAIx00B2ss».

aeaiax00F0oaiaio eiii’thoax00F0ieo oaoiieiax00B3e.

eaoaaex00F0a x00B3ioix00F0iaoeee.

x00D0aaex00B3caoex00B3y x00B3aea? ax00F0eoiaoe/iiai eiaeoaaiiy.

Eox00F0niaa x00F0iaioa.

nooaeaioa /aoaax00F0oiai eox00F0no.

Ex00F0aa/aiea x00B2aaia.

Iaoeiaee eax00F0x00B3aiee.

e. ox00B3c-iao. i.

aeioe. Noaax00F0ianueeee A.A.

Ee?a — 1999.

Cix00B3no.

1. Anooi.

2. x00B2aeay ax00F0eoiaoe/iiai eiaeoaaiiy.

3. Ix00F0iax00F0aia aeey ax00F0eoiaoe/iiai eiaeoaaiiy.

3.1 Aeaix00F0eoi ax00F0eoiaoe/iiai eiaeoaaiiy.

3.2 Aeaix00F0eoi ax00F0eoiaoe/iiai aeaeiaeoaaiiy.

4. Caoaaaeaiiy aei x00F0aaex00B3caoex00B3?.

4.1 Ix00F0ex00F0iuoaaix00B3 iax00F0aaea/a x00B3 iox00F0eiaiiy x00B3ioix00F0iaoex00B3?.

4.2 Aaaeaia aeeix00F0enoaiiy oex00B3ei/eneaii? ax00F0eoiaoeee.

4.3 Aoaeoeaia x00F0aaex00B3caoex00B3y iiaeaex00B3.

5. x00D0aaex00B3caoex00B3y iiaeaex00B3.

6. Aeiaaaeaiiy ix00F0aaeeueiinox00B3 aeaeiaeoaaiiy.

7. Ix00F0iaeaia iax00F0aiiaiaiiy x00B3 caaax00F0oaiiy eiaeoaaiiy.

7.1 Ax00B3ae'x00BAiia iax00F0aiiaiaiiy.

7.2 Iax00F0aiiaiaiiy.

7.3 Caaax00F0oaiiy eiaeoaaiiy.

8. Iiaeaex00B3 aeey ax00F0eoiaoe/iiai eiaeoaaiiy.

8.1 Ox00B3eniaaix00B3 iiaeaex00B3.

8.2 Aaeaioeaia iiaeaeue.

9. Aoaeoeaix00B3noue noeneaiiy.

10. Canoinoaaiiy ax00F0eoiaoe/iiai eiaeoaaiiy.

10.1 Eiaeoaaiiy /ix00F0ii — ax00B3eeo ciax00F0aaeaiue.

10.2 Eiaeoaaiiy aeiax00B3eueii x00F0iciiaex00B3eaieo oex00B3eeo /enae.

Aeiaeaoie 1. Aeiaaaeaiiy aeaeiaeoth/i? iax00F0x00B3aiinox00B3.

Aeiaeaoie 2. x00D0iai/ee eiae aeey aaeaioeaiiai ax00F0eoiaoe/iiai noeneaiiy.

Ex00B3oax00F0aoox00F0a.

Anooi.

Ix00F0iaeaia noeneaiiy oa eiaeoaaiiy x00B3ioix00F0iaoex00B3? c’yaeeanue iaaaaaoi x00F0aix00B3oa ix00B3ae, aeania, oax00F0ix00B3i «x00B3ioix00F0iaoex00B3y». Caaaeax00BAii, ui ix00F0eiaeiix00B3 ca /anx00B3a x00D0einiei? x00B3iiax00F0x00B3? ax00F0ix00B3y aeeix00F0enoiaoaaea iaoiae oeox00F0oaaiiy iiax00B3aeiieaiue c iaoith ?? caoenoo ax00B3ae aix00F0iax00B3a. Oae caaiee oeox00F0 Oeacax00F0y noaa iax00F0oei c ax00B3aeiieo ia nueiaiaeix00B3 iaoiaex00B3a oeox00F0oaaiiy c oax00BAiiei eeth/ii. x00B2ioei ix00F0eeeaaeii eiaeoaaiiy x00BA ienaiix00B3noue, yea aeieeea oae aeaaii, ui oi/ieo aeaieo ix00F0i eiiex00F0aoiee /an ?? iiyae ia x00B3niox00BA x00B3, iaaooue, ix00B3eiee ia aoaea ciaeaeaii.

A aex00F0oax00B3e iieiaeix00B3 OO-ai noiex00B3ooy c aeiaeaeaiiyi oa x00F0icaeoeii AII ix00F0iaeaia noeneaiiy oa eiaeoaaiiy ix00F0eaax00F0ioea aei naaa oaaao, ai c /enoi oaix00F0aoe/ii? iax00F0aoaix00F0eeany a ix00F0eeeaaeio oa aex00F0ae iaiaox00B3aeio. Nox00F0x00B3iei cx00F0inee ianyae aeaieo, c’yaeeanue iiox00F0aaa a iax00F0aaea/x00B3 aeenex00F0aoii? x00B3ioix00F0iaoex00B3? ia aeaeaex00B3 ax00B3aenoaix00B3 c aeinoaoiueith iaaex00B3eix00B3noth, ix00F0iaeaia caoenoo oaei? x00B3ioix00F0iaoex00B3? ax00B3ae ianaieoex00B3aiiaaiiai aeinooio x00B3 o. ae. C x00F0icaeoeii eiii’thoax00F0ieo iax00F0aae (ciex00F0aia, INTERNET) ianya x00B3ioix00F0iaoex00B3?, ui iax00F0aaeax00BAoueny, oaeaeei cx00F0inoax00BA x00B3 aeiaaax00BA ?? ix00B3ix00B3ix00B3caoex00B3? oeyoii niaoeeox00B3/iiai eiaeoaaiiy aeey ix00B3aeox00F0eiaiiy oaeaeeiaex00B3? iax00F0aaex00B3. Iiaeia iaaanoe aaaaoi x00B3ioeo canoinoaaiue eiaeoaaiiy x00B3ioix00F0iaoex00B3?.

Ax00F0eoiaoe/ia eiaeoaaiiy x00BA iaeiei c iax00F0niaeoeaieo iaoiaex00B3a noeneo x00B3ioix00F0iaoex00B3?, oa, a aeayeiio x00F0icoix00B3iix00B3, ?? oeox00F0oaaiiy. Oea eiaeoaaiiy aeicaieyx00BA iaeoaaoe neiaiee aox00B3aeiiai aeoaax00B3oo ca oiiae, ui x00F0iciiaex00B3e /anoio oeeo neiaiex00B3a ax00B3aeiiee. Eiioeaioex00B3y iaoiaeo aoea x00F0icx00F0iaeaia Aex00B3anii a 60-o x00F0ieao. Ix00B3ney oeueiai iaoiae aoa nooox00BAai x00F0icaeiooee oa aaeineiiaeaiee. Ax00F0eoiaoe/ia eiaeoaaiiy x00BA iioeiaeueiei, aeinyaax00BA oaix00F0aoe/ii? ax00F0aieoex00B3 nooiaiy noeneo, — aiox00F0iix00B3? aox00B3aeiiai iioieo.

2. x00B2aeay ax00F0eoiaoe/iiai eiaeoaaiiy.

Ix00F0e ax00F0eoiaoe/iiio eiaeoaaiix00B3 oaeno ix00F0aaenoaaeyx00BAoueny /eneaie c ieaaath/ith eiiith a x00B3ioax00F0aaex00B3 ax00B3ae 0 aei 1. A ix00F0ioeanx00B3 eiaeoaaiiy oaenoo x00B3ioax00F0aae, ui eiai ax00B3aeiax00F0aaeax00BA — ciaioox00BAoueny, a ex00B3eueex00B3noue ax00B3ox00B3a aeey eiai ix00F0aaenoaaeaiiy cax00B3eueoox00BAoueny. Ianooiix00B3 neiaiee oaenoo ciaioothoue aaee/eio x00B3ioax00F0aaea, aeoiaey/e c cia/aiue ?o eiiax00B3x00F0iinoae, yex00B3 aecia/athoueny iiaeaeeth. Ax00B3eueo eiiax00B3x00F0ix00B3 neiaiee x00F0iaeyoue oea a iaiox00B3e ix00B3x00F0x00B3 ix00B3ae iaio eiiax00B3x00F0ix00B3 oa, oaeei /eiii, aeiaeathoue iaioa ax00B3ox00B3a aei x00F0acoeueoaoo.

Iax00F0aae ii/aoeii x00F0iaioe ax00B3aeiiax00B3aeiee aei oaenoo x00B3ioax00F0aae x00BA [0; 1). Ix00F0e iax00F0iaoex00B3 ianooiiiai neiaieo eiai oex00F0eia caoaeox00BAoueny ca x00F0aooiie aeaex00B3eaiiy oeueiio neiaieo /anoeie x00B3ioax00F0aaeo. Iaix00F0eeeaae, canoinoaii aei oaenoo «aax00B3x00B3!» aeoaax00B3oa {a, a, x00B3, i, u, ! } iiaeaeue c iinox00B3eieie eiiax00B3x00F0iinoyie, ui caaeaix00B3 a oaaeeoex00B3 1.

Oaaeeoey SEQ Oaaeeoea * ARABIC 1. Ix00F0eeeaae iinox00B3eii? iiaeaex00B3 aeey aeoaax00B3oa {a, a, x00B3, i, u, ! }.

Neiaie Eiiax00B3x00F0ix00B3noue x00B2ioax00F0aae.

A 0,2 [0,0; 0,2).

A 0,3 [0,2; 0,5).

x00B2 0,1 [0,5; 0,6).

I 0,2 [0,6; 0,8).

O 0,1 [0,8; 0,9).

! 0,1 [0,9; 1,0).

x00B2 eiaeoaaeueieeo, x00B3 aeaeiaeoaaeueieeo ax00B3aeiii, ui ia naiiio ii/aoeo x00B3ioax00F0aae x00BA [0; 1). Ix00B3ney iax00F0aaeyaeo iax00F0oiai neiaieo «a», eiaeoaaeueiee caoaeox00BA x00B3ioax00F0aae aei [0,2; 0,5), yeee iiaeaeue aeaex00B3eyx00BA oeueiie neiaieo. Aex00F0oaee neiaie «a» caoceoue oeae iiaee x00B3ioax00F0aae aei iax00F0oi? eiai i’yoi? /anoeia, inex00B3eueee aeey «a» aeaex00B3eaii ox00B3eniaaiee x00B3ioax00F0aae [0,0; 0,2). A x00F0acoeueoaox00B3 iox00F0eiax00BAii x00F0iai/ee x00B3ioax00F0aae [0,2; 0,26), ai iiiax00F0aaeix00B3e x00B3ioax00F0aae iaa oex00F0eio a 0,3 iaeeieoex00B3 oa iaeia i’yoa ax00B3ae iueiai x00BA 0,06. Ianooiiiio neiaieo «x00B3» ax00B3aeiiax00B3aeax00BA ox00B3eniaaiee x00B3ioax00F0aae [0,5; 0,6), ui canoiniaii aei x00F0iai/iai x00B3ioax00F0aaeo [0,2; 0,26) caoaeox00BA eiai aei x00B3ioax00F0aaeo [0,23; 0,236). Ix00F0iaeiaaeoth/e oaeei naia niiniaii iax00BAii:

Ia ii/aoeo [0.0; 1.0).

Ix00B3ney iax00F0aaeyaeo «a» [0.2; 0.5).

Ix00B3ney iax00F0aaeyaeo «a» [0.2; 0.26).

Ix00B3ney iax00F0aaeyaeo «x00B3» [0.23; 0.236).

Ix00B3ney iax00F0aaeyaeo «x00B3» [0.233; 0.2336).

Ix00B3ney iax00F0aaeyaeo «!» [0.23 354; 0.2336).

Ix00F0eionoeii, ui ana oa, ui aeaeiaeoaaeueiee ciax00BA ix00F0i oaeno, oea ex00B3ioeaaee x00B3ioax00F0aae [0,23 354; 0,2336). Ax00B3i ax00B3aex00F0aco ae cx00F0icoix00B3x00BA, ui iax00F0oee caeiaeiaaiee neiaie — oea «a», oiio ui ix00B3aenoieiaee x00B3ioax00F0aae oex00B3eeii eaaeeoue a x00B3ioax00F0aaex00B3, ui aoa aeaex00B3eaiee oeueiio neiaieo ax00B3aeiiax00B3aeii aei Oaaeeoex00B3 1. Oaiax00F0 iiaoix00F0eii aex00B3? eiaeoaaeueieea:

Nii/aoeo [0.0; 1.0).

Ix00B3ney iax00F0aaeyaeo «a» [0.2; 0.5).

Cax00B3aene cx00F0icoix00B3ei, ui aex00F0oaee neiaie — oea «a», inex00B3eueee oea ix00F0ecaaaea aei x00B3ioax00F0aaeo [0,2; 0,26), yeee oex00B3eeii ix00B3noeoue a niax00B3 ix00B3aenoieiaee x00B3ioax00F0aae [0,23 354; 0,2336). Ix00F0aoethth/e a oaeee niinx00B3a, aeaeiaeoaaeueiee aeoyaox00BA aanue oaeno.

Aeaeiaeoaaeueiee ia iax00BA iiox00F0aae ciaoe cia/aiiy iaio iaae ix00B3aenoieiaiai x00B3ioax00F0aaeo, yeee aoa iaeax00F0aeaiee ax00B3ae eiaeoaaeueieea. Iaax00B3oue iaeiiai cia/aiiy, ui eaaeeoue anax00F0aaeeix00B3 iueiai, iaix00F0eeeaae, 0,23 355 aaea aeinoaoiuei. (x00B2iox00B3 /enea — 0,23 354, 0,23 357 oa iaax00B3oue 0,23 354 321 — oex00B3eeii ix00F0eaeaoix00B3). Iaeiae, uia caaax00F0oeoe ix00F0ioean, aeaeiaeoaaeueieeo iiox00F0x00B3aii naix00BA/anii x00F0icix00B3ciaoe ex00B3iaoeue oaenoo. Ex00F0x00B3i oiai, iaeia e oa naia /enei 0,0 iiaeia ix00F0aaenoaaeoe x00B3 ye «a», x00B3 ye «aa», x00B3 ye «aaa» x00B3 o. ae. Aeey onoiaiiy iaiix00F0icoix00B3iiy ie iiaeiix00B3 iicia/aoe caaax00F0oaiiy eiaeiiai oaenoo niaoex00B3aeueiei neiaieii EOF, ui ax00B3aeiiee x00B3 eiaeoaaeueieeo, x00B3 aeaeiaeoaaeueieeo. Aeey aeoaax00B3oo c oaaeeoex00B3 1 c oex00B3x00BAth iaoith, x00B3 ox00B3eueee c iath, aoaea aeeix00F0enoiaoaaoeny neiaie «!». Eiee aeaeiaeoaaeueiee conox00F0x00B3/ax00BA oeae neiaie, oi ax00B3i caaax00F0oox00BA nax00B3e ix00F0ioean.

Aeey ox00B3eniaaii? iiaeaex00B3, yea caaeax00BAoueny iiaeaeeth oaaeeoex00B3 1, aiox00F0iix00B3y 5-oe neiaieueiiai oaenoo «aax00B3x00B3!» aoaea -log 0,3 — log 0,2 — log 0,1 — log 0,1 — log 0,1 = - log 0,6 (4,22. (Ooo canoiniaox00BAii eiaax00F0eo c iniiaith 10, ai aeuaiaaaaeaia eiaeoaaiiy aeeiioaaeiny aeey aeanyoeiaeo /enae). Oea iiynithx00BA, /iio iiox00F0x00B3aii 5 aeanyoeiaeo oeeox00F0 aeey eiaeoaaiiy oeueiai oaenoo. Oaeei /eiii, oex00F0eia ix00B3aenoieiaiai x00B3ioax00F0aaeo x00BA 0,2336 — 0, 23 354 = 0,6, a aiox00F0iix00B3y — ax00B3ae'x00BAiiee aeanyoeiaee eiaax00F0eoi oeueiai /enea. Cae/aeii ie ix00F0aoethx00BAii c aeax00B3eeiaith ax00F0eoiaoeeith, iax00F0aaeax00BAii aeax00B3eeiax00B3 /enea oa aeix00B3x00F0thx00BAii aiox00F0iix00B3th a ax00B3oao.

I’yoe aeanyoeiaeo oeeox00F0 caeax00BAoueny caaaaaoi aeey eiaeoaaiiy oaenoo c /ioex00F0ueio aieinieo! Iaaooue ia cianx00B3i aaeaei ao caex00B3i/oaaoe ix00F0eeeaae x00F0icaix00F0oaiiyi, a ia coeneaiiyi. Iaeiae cx00F0icoix00B3ei, ui x00F0x00B3cix00B3 iiaeaex00B3 aeathoue x00F0x00B3cio aiox00F0iix00B3th. Ex00F0aua iiaeaeue, iiaoaeiaaia ia aiaex00B3cx00B3 iex00F0aieo neiaiex00B3a oaenoo «aax00B3x00B3!», x00BA oaea iiiaeeia /anoio neiaiex00B3a: {"a" (0,2), «a» (0,2), «x00B3» (0,4), «!» (0,2) }. Aiia aeax00BA aiox00F0iix00B3th, ui aeix00F0x00B3aithx00BA 2,89 a aeanyoeiax00B3e nenoaix00B3 ax00B3aeex00B3eo, oiaoi eiaeox00BA aeox00B3aeiee oaeno /eneii c ox00F0ueio oeeox00F0. Iaeiae, ax00B3eueo neeaaeix00B3 iiaeaex00B3, ye ax00B3aeix00B3/aeiny x00F0aix00B3oa, aeathoue a caaaeueiiio aeiaaeeo iaaaaaoi ex00F0aux00B3e x00F0acoeueoao.

3. Ix00F0iax00F0aia aeey ax00F0eoiaoe/iiai eiaeoaaiiy.

Ia x00F0enoieo 1 iieacaii ox00F0aaiaio inaaaeieiaeo, yeee iix00BAaeiox00BA ix00F0ioeaaeox00F0e eiaeoaaiiy oa aeaeiaeoaaiiy, yex00B3 aoei aeeeaaeaii a iiiax00F0aaeiueiio x00F0icaex00B3ex00B3. Neiaiee a iueiio ioiax00F0othoueny ye 1, 2, 3… *anoioiee x00B3ioax00F0aae aeey x00B3-oiai neiaieo caaeax00BAoueny ax00B3ae cum_freeq[i] aei cum_freeq[i-1]. Ix00F0e ciaioaiix00B3 x00B3 cum_freeq[i] cx00F0inoax00BA oae, ui cum_freeq[0] = 1. (Ix00F0e/eia oaeiai «caix00F0ioiueiai» aeiaiaix00F0o iieyaax00BA a oiio, ui cum_freeq[0] aoaea iiox00B3i ix00B3noeoe iix00F0iaex00B3coth/ee iiiaeiee, yeee cx00F0o/ii caax00F0x00B3aaoe ia ii/aoeo ianeao). Iioi/iee x00F0iai/ee x00B3ioax00F0aae caaeax00BAoueny a [low; high] x00B3 aoaea a naiiio ii/aoeo aeix00F0x00B3aithaaoe [0; 1) x00B3 aeey eiaeoaaeueieea, x00B3 aeey aeaeiaeoaaeueieea.

Ia aeaeue, oeae inaaaeieiae cia/ii nix00F0iuaiee, oiaex00B3 ye a ix00F0aeoe/iiio canoinoaaiix00B3 x00B3niox00BA aeaex00B3eueea /eiieex00B3a, yex00B3 oneeaaeiththoue x00B3 eiaeoaaiiy, x00B3 aeaeiaeoaaiiy.

3.1 Aeaix00F0eoi ax00F0eoiaoe/iiai eiaeoaaiiy.

/*C eiaeiei ianooiiei neiaieii oaenoo caax00F0oaoeny */.

/*aei ix00F0ioeaaeox00F0e encode_symbol () */.

/*Iax00F0aax00B3x00F0eoe, ui oax00F0ix00B3iaeueiee neiaie caeiaeiaaiee inoaiix00B3i*/.

/*Aeaanoe iaeax00F0aeaia cia/aiiy x00B3ioax00F0aaeo [low; high) */.

encode_symbol (symbol, cum_freq).

range = high — low.

high = low + range*cum_freq[symbol — 1].

low = low + range*cum_freq[symbol].

3.2 Aeaix00F0eoi ax00F0eoiaoe/iiai aeaeiaeoaaiiy.

/* Value — oea /enei, yea iaeax00F0aeaii ia aox00B3ae*/.

/*Caax00F0oaiiy aei ix00F0ioeaaeox00F0e decode_symbol () aei oiai iiiaioo*/.

/*iiee aiia ia iiaax00F0ia oax00F0ix00B3iaeueiee neiaie*/.

decode_symbol (cum_freq).

iiooe oaeiai neiaieo, ui.

cum_freq[symbol] <= (value — low) / (high — low) < cum_freq[symbol — 1].

/*oea caaacia/ox00BA x00F0icix00B3uaiiy Value a iaaeao iiaiai x00B3ioax00F0aaeo*/.

/*[low; high], ui ax00B3aeiax00F0aaeaii a caaax00F0oaiix00B3 ix00F0iax00F0aie*/.

range = high — low.

high = low + range*cum_freq[symbol — 1].

low = low + range*cum_freq[symbol].

return symbol.

x00D0enoiie 1. Inaaaeieiae ax00F0eoiaoe/iiai eiaeoaaiiy oa aeaeiaeoaaiiy.

4. Caoaaaeaiiy aei x00F0aaex00B3caoex00B3?.

4.1 Ix00F0ex00F0iuoaaix00B3 iax00F0aaea/a x00B3 iox00F0eiaiiy x00B3ioix00F0iaoex00B3?.

Iaaaaeaiee aeaix00F0eoi eiaeoaaiiy ix00B3/iai ia iax00F0aaeax00BA aei iiaiiai caaax00F0oaiiy eiaeoaaiiy anueiai oaenoo, a oaeiae x00B3 aeaeiaeoaaeueiee ia ii/eiax00BA oeae ix00F0ioean, iiee ia iox00F0eiax00BA noeniaiee oaeno oex00B3eeii. Aeey ax00B3eueoinox00B3 aeiaaeex00B3a iaiaox00B3aeai iiaoaiiee x00F0aaeei aeeiiaiiy .

4.2 Aaaeaia aeeix00F0enoaiiy oex00B3ei/eneaii? ax00F0eoiaoeee.

Iiox00F0x00B3aia aeey ix00F0aaenoaaeaiiy x00B3ioax00F0aaeo [low; high] oi/ix00B3noue cx00F0inoax00BA x00F0acii c aeiaaeeiith oaenoo. Iiaoaiia aeeiiaiiy aeiiiiaaax00BA aex00F0x00B3oeoe oeth ix00F0iaeaio, aea aeiaaax00BA ix00F0e oeueiio oaaaeiiai iaex00B3eo iiaeeeaiai iax00F0aiiaiaiiy oa ax00B3ae'x00BAiiiai iax00F0aiiaiaiiy.

4.3 Aoaeoeaia x00F0aaex00B3caoex00B3y iiaeaex00B3.

x00D0aaex00B3caoex00B3y iiaeaex00B3 iiaeiia ix00B3ix00B3ix00B3coaaoe /an aecia/aiiy ianooiiiai neiaieo aeaix00F0eoiii aeaeiaeoaaiiy. Ex00F0x00B3i oiai, aaeaioeaix00B3 iiaeaex00B3 iiaeiix00B3 oaeiae ix00B3ix00B3ix00B3coaaoe /an, yeee aeiaaax00BAoueny aeey ix00B3aeox00F0eiaiiy iaeiie/aieo /anoio.

5. x00D0aaex00B3caoex00B3y iiaeaex00B3.

Naia x00F0aaex00B3caoex00B3y aoaea iaaiaix00F0thaaoeny a ianooiiiio x00F0icaex00B3ex00B3, a ooo ox00F0aaa eeoa oix00F0eiooeny ox00B3eueee x00B3ioax00F0oaeno c iiaeaeeth. sse ax00B3aeiii, aaeo ix00F0aaenoaaeyx00BA niaith oex00B3ea /enei ax00B3ae 0 aei 255 (oei char). Ooo ie ix00F0aaenoaaeyx00BAii aaeo ye oex00B3ea /enei ax00B3ae 1 aei 257 aeeth/ii (oei index), aea EOF ox00F0aeoox00BAoueny ye 257-e neiaie. Aoei a aeiax00F0a ax00B3aenix00F0ooaaoe iiaeaeue a iix00F0yaeeo ciaioaiiy /anoio aeey ix00B3ix00B3ix00B3caoex00B3? ex00B3eueeinox00B3 aeeiiaiiy oeeeeo aeaeiaeoaaiiy. Iax00F0aoaix00F0aiiy c oeio char a index, oa iaaiaee, x00F0aaex00B3ciaaii ca aeiiiiiaith aeaio oaaeeoeue — index_to_char[] i char_to_index[]. A aaeaioeaix00B3e iiaeaex00B3 aeeiiox00BAoueny iax00F0aeiaeoaaiiy, yea ix00F0enaithx00BA iae/anox00B3oei neiaieai iaeaiueex00B3 x00B3iaeaene.

Eiiax00B3x00F0iinox00B3 ix00F0aaenoaaeythoueny a iiaeaex00B3 ye oex00B3ei/enaeaix00B3 ex00B3/eeueieee /anoio, a iaeiie/oaaix00B3 /anoioe caax00F0x00B3aathoueny a ianeax00B3 cum_freq[]. sse x00B3 a iiiax00F0aaeiueiio aeiaaeeo, oeae ianea — «caix00F0ioix00B3e», x00B3 ex00B3/eeueiee caaaeueii? /anoioe, yeee aeeix00F0enoiaox00BAoueny aeey iix00F0iaex00B3caoex00B3? anx00B3o /anoio, x00F0icix00B3uox00BAoueny a cum_freq[0]. Iaeiie/oaaix00B3 /anoioe ia iiaeiix00B3 iax00F0aaeuoaaoe anoaiiaeaiiee a Max_frequency iaeneioi, a x00F0aaex00B3caoex00B3y iiaeaex00B3 iiaeiia caiiax00B3aaoe iax00F0aiiaiaiith ax00B3aeiiax00B3aeiei iaooaaoaaiiyi. Iaiaox00B3aeii oaeiae ix00F0eiaeiix00B3 ia 1 caaacia/eoe x00F0x00B3cieoeth ix00B3ae aeaiia nonx00B3aeieie cia/aiiyie cum_freq[], a ix00F0ioeaiiio aeiaaeeo neiaie, ui iax00F0aaeyaeax00BAoueny, ia aoaea iax00F0aaeaiee.

6. Aeiaaaeaiiy ix00F0aaeeueiinox00B3 aeaeiaeoaaiiy.

Iax00F0aax00B3x00F0eii ix00F0aaeeueix00B3noue aecia/aiiy ix00F0ioeaaeox00F0ith decode_symbol () ianooiiiai neiaieo. C inaaaeieiaeo ia x00F0enoieo 1 cx00F0icoix00B3ei, ui decode_symbol () iiaeiia aeeix00F0enoiaoaaoe Value aeey iiooeo neiaiea, yeee ix00F0e eiaeoaaiix00B3 neix00F0ioea x00F0iai/ee x00B3ioax00F0aae oae, ui ax00B3i ix00F0iaeiaaeox00BA aeeth/aoe a naaa Value. A x00F0iai/x00B3e ix00F0iax00F0aix00B3 a decode_symbol () aecia/ax00BAoueny oaeee neiaie, aeey yeiai:

cum_freq [symbol] ((((value — low +1)*cum_freq [0]-1)/(high — low + 1) (< cum_freq [symbol — 1], aea ((icia/ax00BA iiax00F0aoex00B3th acyooy oex00B3ei? /anoeie — aex00B3eaiiy c ax00B3aeeeaeaiiyi aex00F0iaiai? /anoeie. Iieacaii, ui oea iax00F0aaeaa/ax00BA:

low + (((high — low + 1)*cum_freq [symbol]) / cum_freq [0] ((value (low + (((high — low +1)*cum_freq [symbol — 1]) / cum_freq [0](, oaeei /eiii, ui value iaeaaeeoue iiaiio x00B3ioax00F0aaeo, yeee aex00F0aoiaox00BAoueny ix00F0ioeaaeox00F0ith decode_symbol (). Oea aax00F0aioox00BA eix00F0aeoix00B3noue aecia/aiiy eiaeiiai neiaieo iiax00F0aoex00B3x00BAe aeaeiaeoaaiiy.

7. Ix00F0iaeaia iax00F0aiiaiaiiy x00B3 caaax00F0oaiiy eiaeoaaiiy.

7.1 Ax00B3ae'x00BAiia iax00F0aiiaiaiiy.

sse iieacaii a inaaaeieiaex00B3, ax00F0x00B3oiaoe/ia eiaeoaaiiy ix00F0aoethx00BA ca aeiiiiiaith ianooaaoaaiiy iaeiie/aieo eiiax00B3x00F0iinoae, yex00B3 iaaeathoueny iiaeaeth a x00B3ioax00F0aaex00B3 [low; high] aeey eiaeiiai neiaieo, ui iax00F0aaeax00BAoueny. Ix00F0eionoeii, ui low i high oae aeecueex00B3 iaeei aei iaeiiai, ui iiax00F0aoex00B3y ianooaaoaaiiy ix00F0ecaiaeeoue iaeax00F0aeaix00B3 ax00B3ae iiaeaex00B3 x00F0x00B3cix00B3 neiaiee aei iaeiiai oex00B3eiai /enea, yea aoiaeeoue a [low; high]. A oaeiio aeiaaeeo iiaeaeueoa eiaeoaaiiy ix00F0iaeiaaeoaaoe iaiiaeeeai. Oiio eiaeoaaeueiee iiaeiai nex00B3aeeoaaoe ca oei, uia x00B3ioax00F0aae [low; high] caaaeaee aoa aeineoue oex00F0ieei. Iaeix00F0inox00B3oei caniaii aeey oeueiai x00BA caaacia/aiiy oex00F0eie x00B3ioax00F0aaeo ia iaioae Max_frequency — iaeneiaeueiiai cia/aiiy noie anx00B3o iaeiie/oaaieo /anoio.

Ix00F0iaeaia ax00B3ae'x00BAiiiai iax00F0aiiaiaiiy x00F0icaeyaeax00BAoueny ox00B3eueee ax00B3aeiinii eiaeoaaeueieea, oiio ui ix00F0e aeaeiaeoaaiix00B3 eiaeiiai neiaieo ix00F0ioean ex00F0ieox00BA ca iiax00F0aoex00B3x00BAe eiaeoaaiiy, x00B3 ax00B3ae'iia iax00F0aiiaiaiiy ia aeieeia, yeui aeeiiox00BAoueny oaea naia ianooaaoaaiiy c oeie ae naieie oiiaaie.

7.2 Iax00F0aiiaiaiiy.

Oaiax00F0 x00F0icaeyiaii iiaeeeax00B3noue iax00F0aiiaiaiiy ix00F0e oex00B3ei/eneaiiio iiiaeaiix00B3. Iax00F0aiiaiaiiy ia aeieeia, yeui aeiaooie range*Max_frequency aix00B3uox00BAoueny a oex00B3ea neiai, ai iaeiie/aix00B3 /anoioe ia iiaeooue iax00F0aaeuoaaoe Max_frequency. Range iax00BA iaeax00B3eueoa cia/aiiy a Top_Value + 1, oiio iaeneiaeueii iiaeeeaee aeiaooie x00BA 216*(214 — 1), yea iaioa 230. Aeey aecia/aiiy code_value oa range aeeix00F0enoaiee oei long, uia caaacia/eoe 32-o ax00B3oiao oi/ix00B3noue ax00F0eoiaoe/ieo ia/eneaiue.

7.3 Caaax00F0oaiiy eiaeoaaiiy.

Ix00F0e caaax00F0oaix00B3 ix00F0ioeano eiaeoaaiiy iaiaox00B3aeii iineaoe oix00B3eaeueiee oax00F0ix00B3iaeueiee neiaie (EOF-neiaie), a iiox00B3i iineaoe aeinoaoith ex00B3eueex00B3noueax00B3ox00B3a aeey aax00F0aiox00B3? oiai, ui caeiaeiaaiee x00F0yaeie iiox00F0aieoue a ix00B3aenoieiaee x00F0iai/ee x00B3ioax00F0aae. *ax00F0ac oa, ui ix00F0ioeaaeox00F0a done_encoding () iiaea aooe «aiaaiaia», ui low i high iaiaaeaix00B3 aai oae, ui:

low < First_qtr < Half (high, aai.

low < Half < Third_qtr (high,.

oi cia/aiith ox00F0aaa iax00F0aaeaoe 01 aai 10 ax00B3aeiiax00B3aeii, aeey aeaeaeaiiy iaaecia/aiinox00B3, yea caeeoeeanue. Oaeei /eiii EOF oix00B3eaeueii aecia/ax00BAoueny inoaiix00B3ie iax00F0aaeaieie ax00B3oaie.

8. Iiaeaex00B3 aeey ax00F0eoiaoe/iiai eiaeoaaiiy.

Ix00F0iax00F0aia iiaeiia ix00F0aoethaaoe c iiaeaeeth, yea yaeyx00BA niaith iax00F0o iax00F0aeiaeoth/eo oaaeeoeue index_to_char [] i char_to_index [], x00B3 ianea iaeiie/aieo /anoio cum_freq []. Aei inoaiiueiai ianeao aenoaathoueny oaex00B3 aeiiae:

num_freq [i — 1] (cum_freq [i];

Ix00B3eiee ia x00F0iaeoueny nix00F0iaa eiaeoaaoe neiaie x00B3, aeey yeiai num_freq [i — 1] = cum_freq [i];

num_freq [0] (Max_frequency.

sseui oex00B3 oiiae aeeiiothoueny, cia/aiiy a ianeax00B3 ia iiaeiix00B3 iaoe ca’yceo c aex00B3enioie cia/aiiyie iaeiie/aieo /anoio neiaiex00B3a oaenoo. x00B2 aeaeiaeoaaiiy, x00B3 eiaeoaaiiy aoaeooue ix00F0aoethaaoe eix00F0aeoii, ix00F0e /iio inoaiiueiio aoaea ox00F0aaa iaioa ix00B3noey, yeui /anoioe oi/ix00B3.(Caaaeax00BAii onix00B3oia eiaeoaaiiy «aax00B3x00B3!» o ax00B3aeiiax00B3aeiinox00B3 aei iiaeaex00B3 c oaaeeoex00B3 1, ye, acaaaex00B3, ia ax00B3aeiax00F0aaeax00BA nix00F0aaaeiuei? /anoioe a oaenox00B3).

8.1 Ox00B3eniaaix00B3 iiaeaex00B3.

Iaeix00F0inox00B3oith iiaeaeeth x00BA oaea iiaeaeue, a yex00B3e /anoioe neiaiex00B3a iinox00B3eix00B3. Iiaeaeue c oaaeeoex00B3 1 caaeax00BA iinox00B3eix00B3 /anoioe neiaiex00B3a aeey aeoaax00B3oo {a, e, i, u, o, !}. Aeey noeneo aiaex00B3enueeeo oaenox00B3a iiaeia aeeix00F0enoaoe /anoioe c /anoeie Naiaea Ax00F0aoia. Ix00F0ioeaaeox00F0a x00B3ix00B3oex00B3aex00B3caoex00B3? start_model () ix00F0inoi ix00B3aex00F0aoiaox00BA iaeiie/aio aax00F0nx00B3th oeeo /anoio, nii/aoeo x00B3ix00B3oex00B3aex00B3coaaaoe oaaeeoex00B3 iax00F0aeiaeoaaiiy. Oaeaeex00B3noue aeeiiaiiy ix00F0ioeano eiaeoaaiiy oa aeaeiaeoaaiiy iiaeia ix00F0eneix00F0eoe, yeui oex00B3 oaaeeoex00B3 iax00F0aaiix00F0yaeeoaaoe oae, uia iaeaaeeaaix00B3ox00B3 neiaiee x00F0icix00B3uoaaeeny ia ii/aoeo ianeao cum_freq []. *ax00F0ac oa, ui iiaeaeue x00BA iinox00B3eiith, ix00F0ioeaaeox00F0a update_model () aoaea ix00F0inoi ionoith.

Nox00F0iaith iiaeaeeth x00BA oaea iiaeaeue, a yex00B3e /anoioe neiaiex00B3a oaenoo oi/ii ax00B3aeiiax00B3aeathoue niaoeeox00B3eaoex00B3? iiaeaex00B3. Iaix00F0eeeaae, ox00B3eniaaia iiaeaeue c ix00F0iax00F0aie aeecueea aei nox00F0iai? iiaeaex00B3 aeey aeayeiai ox00F0aaiaioa c Naiaea Ax00F0aoia, cax00B3aeee ?? aoei acyoe. Iaeiae, aeey oiai, uia aooe x00B3noeii nox00F0iaith, ?? neiaiee a oeueiio ox00F0aaiaiox00B3, yex00B3 ia c’yaeythoueny, iiaeiix00B3 iaoe ex00B3/eeueieee, ui aeix00F0x00B3aiththoue 0, a ia 1 (x00B3 ix00F0e oeueiio «aeax00F0oaoaaoe» iiaeeeainoyie aox00B3aeieo oaenox00B3a, yex00B3 ix00B3noyoue oex00B3 neiaiee). Ex00F0x00B3i oiai, ex00B3/eeueieee ia iiaeiix00B3 ianooaaoaaoeny aei caaeaii? iaeiie/aii? /anoioe, ye oea cx00F0iaeaii a ix00F0iax00F0aix00B3. Acaaaex00B3, nox00F0iaa iiaeaeue iiaeiia aooe aex00F0aoiaaia e iax00F0aaeaia iax00F0aae iax00F0aneeaiiyi aeania oaenoo. Eex00B3x00F0x00B3 x00B3 Ox00B3oiai iieacaee, ui ix00F0e caaaeueieo oiiaao oea ia aeanoue caaaeueiiai iiex00F0auaiiy noeneo iix00F0x00B3aiyii c iienaiei ieae/a aaeaioeaiei eiaeoaaiiyi.

8.2 Aaeaioeaia iiaeaeue.

Aiia cix00B3ithx00BA /anoioe aaea ciaeaeaieo a oaenox00B3 neiaiex00B3a. Nii/aoeo anx00B3 ex00B3/eeueieee iiaeooue aooe x00F0x00B3aieie, ui ax00B3aeiax00F0aaeox00BA ax00B3aenooix00B3noue ii/aoeiaeo aeaieo, aea ix00F0e iax00F0aaeyaex00B3 eiaeiiai aox00B3aeiiai neiaieo aiie cix00B3iththoueny, iaaeeaeoth/enue aei niinoax00F0aaeoaaieo /anoio. x00B2 eiaeoaaeueiee, x00B3 aeaeiaeoaaeueiee aeeix00F0enoiaothoue iaeiaeiax00B3 ii/aoeiax00B3 cia/aiiy (iaix00F0eeeaae, x00F0x00B3aix00B3 ex00B3/eeueieee) x00B3 iaeei x00B3 oie naiee aeaix00F0eoi iiiaeaiiy, ui aeicaieeoue? o iiaeaeyi caaaeaee caeeoaoeny ia iaeiiio x00F0x00B3aix00B3. Eiaeoaaeueiee iox00F0eiox00BA ianooiiee neiaie, eiaeox00BA eiai oa cix00B3ithx00BA iiaeaeue. Aeaeiaeoaaeueiee c’yniaox00BA ianooiiee neiaie ia iniiax00B3 naix00BA? iioi/ii? iiaeaex00B3, a iiox00B3i iiiaethx00BA ??.

Ix00F0iax00F0aia aeaiiinox00F0ox00BA oaeo aaeaioeaio iiaeaeue, ui x00F0aeiiaiaeox00BAoueny aeey aeeix00F0enoaiiy ix00F0e noeneo oa ax00B3aeiiaeaiix00B3, inex00B3eueee ia ix00F0aeoeoex00B3 aiia x00BA ex00F0auith ix00B3ae ox00B3eniaaia iiaeaeue ca aoaeoeaix00B3noth noeneo. x00B2ix00B3oex00B3aex00B3caoex00B3y ix00F0iaiaeeoueny oaeei naia /eiii, ye aeey ox00B3eniaaii? iiaeaex00B3, ca aeeeth/aiiyi oiai, ui anx00B3 /anoioe anoaiiaeththoueny a ioex00B3. Ix00F0ioeaaeox00F0a update_model (symbol), aeeeeeax00BAoueny c encode_symbol () oa decode_symbol () ix00B3ney iax00F0iaee eiaeiiai neiaieo.

Iiiaeaiiy iiaeaex00B3 x00BA aeineoue aeix00F0iaei c ix00F0e/eie iaiaox00B3aeiinox00B3 ix00B3aeox00F0eiee iaeiie/aieo noi. A ix00F0iax00F0aix00B3 aeeix00F0enoaix00B3 ex00B3/eeueieee /anoio, yex00B3 iioeiaeueii x00F0icix00B3uaix00B3 a ianeax00B3 a iix00F0yaeeo ciaioaiiy nai? o cia/aiue, ui x00BA aoaeoeaiei aeaeii naiiix00F0aaix00B3ciaaiiai ex00B3ix00B3eiiai iiooeo. Ix00F0ioeaaeox00F0a update_model () nii/aoeo iax00F0aax00B3x00F0yx00BA iiao iiaeaeue ia ix00F0aaeiao iax00F0aaeuaiiy iath iaiaaeaiue ca aaee/eiith iaeiie/aii? /anoioe, x00B3 yeui aiii ix00F0enooix00BA, oi ciaioox00BA anx00B3 /anoioe aex00B3eaiiyi ia 2, caaaeath/e ix00F0e oeueiio ia oa, uia ex00B3/eeueieee ia iax00F0aoaix00F0eeeny a 0, x00B3 iax00F0aia/enethx00BA iaeiie/aix00B3 cia/aiiy. Iiox00B3i, yeui oea iaiaox00B3aeii, update_model () iax00F0aaiix00F0yaeeiaox00BA neiaiee aeey oiai, uia x00F0icix00B3noeoe iioi/iee a eiai ax00B3x00F0ix00B3e eaoaaix00F0x00B3? ax00B3aeiinii /anoioiiai iix00F0yaeeo, /ax00F0aoth/e aeey ax00B3aeiax00F0aaeaiiy cix00B3i iax00F0aeiaeoaaeueix00B3 oaaeeoex00B3. A x00F0acoeueoaox00B3, ix00F0ioeaaeox00F0a cax00B3eueoox00BA cia/aiiy ax00B3aeiiax00B3aeiiai ex00B3/eeueieea /anoioe x00B3 aiix00F0yaeeiaox00BA ax00B3aeiiax00B3aeix00B3 iaeiie/aix00B3 /anoioe.

9. Aoaeoeaix00B3noue noeneaiiy.

Acaaaex00B3, ix00F0e eiaeoaaiix00B3 oaenoo ax00F0x00B3oiaoe/iei iaoiaeii, ex00B3eueex00B3noue ax00B3ox00B3a a caeiaeiaaiiio x00F0yaeeo aeix00F0x00B3aithx00BA aiox00F0iix00B3? oeueiai oaenoo ax00B3aeiinii aeeix00F0enoaii? aeey eiaeoaaiiy iiaeaex00B3. Ox00F0e /eiieea aeeeeeathoue iiax00B3x00F0oaiiy oex00B3x00BA? oax00F0aeoax00F0enoeee: aeaeaoee ia caaax00F0oaiiy oaenoo; aeeix00F0enoaiiy ax00F0eoiaoeee c ex00B3ioeaaith oi/ix00B3noth; oaea ianooaaoaaiiy ex00B3/eeueieex00B3a, ui? o noia ia iax00F0aaeuox00BA Max_frequency.

sse aoei iieacaii, aeiaeai c ieo ia x00BA cia/iei. A iix00F0yaeeo aeaex00B3eaiiy x00F0acoeueoaox00B3a ax00F0eoiaoe/iiai eiaeoaaiiy, iiaeaeue aoaea x00F0icaeyaeaoeny ye noaix00F0a (a aecia/aiiio aeua nainx00B3).

Ax00F0eoiaoe/ia eiaeoaaiiy iiaeiia aeineeaoe aeiaeaoeiax00B3 ax00B3oe a ex00B3iaoeue eiaeiiai oaenoo, caex00B3enithth/e oaeei /eiii aeiaeaoeiax00B3 coneeey ia caaax00F0oaiiy oaenoo. Aeey ex00B3eax00B3aeaoex00B3? iaiix00F0icoix00B3iiy c inoaiix00B3i neiaieii ix00F0ioeaaeox00F0a done_encoding () iineeax00BA aeaa ax00B3oe. A aeiaaeeo, eiee iax00F0aae eiaeoaaiiyi iioie ax00B3ox00B3a iax00BA aeieoaaoeny a 8-ax00B3oiax00B3 neiaiee, aoaea iaiaox00B3aeii caaax00F0ooaaoe aei ex00B3ioey aeieo. Oaea eiiax00B3ioaaiiy iiaea aeiaeaoeiai iiox00F0x00B3aoaaoe 9 ax00B3ox00B3a.

Aeaeaoee ix00F0e aeeix00F0enoaiix00B3 ax00F0eoiaoeee c iaiaaeaiith oi/ix00B3noth ix00F0iyaeythoueny a ciaioaix00B3 caeeoex00B3a ix00F0e aex00B3eaiix00B3. Oea aeaeii ix00F0e iix00F0x00B3aiyiix00B3 c oaix00F0aoe/iith aiox00F0iix00B3x00BAth, yea aeaiaeeoue /anoioe x00B3c ex00B3/eeueieex00B3a, yex00B3 oaeei naia /eiii ianooaaothoueny ix00F0e eiaeoaaiix00B3. Ooo aeaeaoee iacia/ix00B3 — iix00F0yaeeo 10^-4 ax00B3ox00B3a / neiaie. Aeiaeaoeiax00B3 aeaeaoee ia ianooaaoaaiiy ex00B3/eeueieex00B3a aeaui ax00B3eueox00B3, aea ana iaeii aeineoue iaex00B3. Aeey eix00F0ioeeo oaenox00B3a (iaioeo 214 aaeo) ?o iaiax00BA. Aea iaax00B3oue c oaenoaie a 105 — 106 aaeox00B3a iaeeaaeix00B3 aeaeaoee, ix00B3aex00F0aoiaaix00B3 aeniax00F0eiaioaeueii, neeaaeathoue iaioa 0,25% ax00B3ae x00F0yaeea, oi eiaeox00BAoueny.

Aaeaioeaia iiaeaeue a ix00F0iax00F0aix00B3, ix00F0e caax00F0icx00B3 iax00F0aaeuaiiy caaaeueiith noiith iaeiie/aieo /anoio cia/aiiy Max_frequency, ciaioox00BA anx00B3 ex00B3/eeueieee. Oea ix00F0ecaiaeeoue aei oiai, ui caaaeoaaoe inoaiix00B3 iiaex00B3? aaae/a, ix00B3ae ax00B3eueo x00F0aiix00B3. Oaeei /eiii, iieacieee iathoue oaiaeaioex00B3th ix00F0inex00B3aeeiaoaaoe cix00B3ie o aox00B3aeix00B3e iinex00B3aeiaiinox00B3, yex00B3 iiaeooue aooe aeoaea eix00F0enieie (ax00B3aeiix00B3 aeiaaeee, eiee iaiaaeaiiy ex00B3/eeueieex00B3a aei 6−7 ax00B3ox00B3a aeaaaei ex00F0aux00B3 x00F0acoeueoaoe, ix00B3ae ix00B3aeaeuaiiy oi/iinox00B3 ax00F0eoiaoeee). Cae/aeii, oea caeaaeeoue ax00B3ae aeaeax00F0aea, aei yeiai canoiniaox00BAoueny iiaeaeue.

10. Canoinoaaiiy ax00F0eoiaoe/iiai eiaeoaaiiy.

10.1 Eiaeoaaiiy /ix00F0ii — ax00B3eeo ciax00F0aaeaiue.

Canoinoaaiiy c oex00B3x00BAth iaoith ax00F0eoiaoe/iiai eiaeoaaiiy x00F0icaeyaeaeiny Eaiaaeiiii oa x00D0ennaiaiii, ui iox00F0eiaee ix00F0e oeueiio /oaeiax00B3 x00F0acoeueoaoe ca aeiiiiiaith iiaeaex00B3, ui aeeix00F0enoiaox00BA ioex00B3ieo eiiax00B3x00F0iinox00B3 eieaix00F0o oi/ee ax00B3aeiinii aeayeiai oaaeiio, ui ?? ioi/ox00BA. Ax00B3i yaeyx00BA niaith noeoiix00B3noue c 10 oi/ie, ui eaaeaoue caax00F0oo oa niax00F0aaeo ax00B3ae iioi/ii?, oiio ix00F0e neaioaaiix00B3 x00F0anox00F0o aiie? e iax00F0aaeothoue. Oea aeax00BA 1024 iiaeeeaeo eiioaenoo, ax00B3aeiinii yeeo, eiiax00B3x00F0ix00B3noue /ix00F0iiai eiex00B3x00F0o a aeaix00B3e oi/oex00B3 ioex00B3ithx00BAoueny aaeaioeaii ii ix00B3x00F0x00B3 iax00F0aaeyaeo ciax00F0aaeaiiy. Ix00B3ney /iai eiaeia iieyx00F0ix00B3noue oi/ee eiaeoaaeany ax00F0eoiaoe/iei iaoiaeii ax00B3aeiiax00B3aeii c oex00B3x00BAth eiiax00B3x00F0ix00B3noth. Oaeee ix00B3aeox00B3ae iiex00F0auea noeneaiiy ia 20 — 30% iix00F0x00B3aiyii c ax00B3eueo x00F0aiix00B3ie iaoiaeaie. Aeey cax00B3eueoaiiy oaeaeeinox00B3 eiaeoaaiiy Eaiaaeii oa x00D0ennaiai canoinoaaee ix00F0eaeeciee iaoiae ax00F0eoiaoe/iiai eiaeoaaiiy, yeee iax00B3eoia iiax00F0aoex00B3? iiiaeaiiy oeyoii ix00F0aaenoaaeaiiy eiiax00B3x00F0iinoae a aeaeyaex00B3 oex00B3eeo nooiaix00B3a aex00F0iao ½/. Eiaeoaaiiy Oaooiaia aeey oeueiai aeiaaeeo ia iiaea aooe aeeix00F0enoaii iaix00F0yio, inex00B3eueee aiii ix00B3eiee ia aeeiiox00BA noeniaiiy aeaioneiaieueiiai aeoaax00B3oo. x00B2ioo iiaeeeax00B3noue aeey ax00F0eoiaoe/iiai eiaeoaaiiy, ui canoiniaox00BAoueny aeey oaeiai aeoaax00B3oo, aeax00BA iiioeyx00F0iee iaoiae eiaeoaaiiy aeiaaeei oex00F0aaex00B3a (run-length method). Iiaeaeue ooo ix00F0eaiaeeoue aeaix00B3 aei iinex00B3aeiaiinox00B3 aeiaaeei nax00F0x00B3e iaeiaeiaeo neiaiex00B3a (iaix00F0eeeaae, ciax00F0aaeaiiy ix00F0aaenoaaeyx00BAoueny aeiaaeeiaie iinex00B3aeiaiinoae /ix00F0ieo oi/ie, yex00B3 eaeooue ca ax00B3eeie, yex00B3 nex00B3aeothoue ca /ix00F0ieie, yeei iax00F0aaeothoue ax00B3eei x00B3 o. ae.). a x00F0acoeueoaox00B3 iiaeiia aooe iax00F0aaeaia iinex00B3aeiaix00B3noue aeiaaeei. Noaiaeax00F0o oaeneix00B3eueieo aiax00F0aox00B3a NNx00B2OO aoaeox00BA eiae Oaooiaia ia iniiax00B3 /anoio, c yeeie /ix00F0ix00B3 x00B3 ax00B3ex00B3 iinex00B3aeiaiinox00B3 x00F0x00B3cieo aeiaaeei c’yaeythoueny a cx00F0aceao aeieoiaiox00B3a. Ox00B3eniaaia ax00F0eoiaoe/ia eiaeoaaiiy, yea aoaea aeeix00F0enoiaoaaoe ox00B3 ae naix00B3 /anoioe, aoaea iaoe ex00F0aux00B3 oax00F0aeoax00F0enoeee, a aaeaioaoex00B3y oaeeo /anoio aeey eiaeiiai iex00F0aiiai aeieoiaioo aoaea ix00F0aoethaaoe ua ex00F0aua.

10.2 Eiaeoaaiiy aeiax00B3eueii x00F0iciiaex00B3eaieo oex00B3eeo /enae.

Aiii /anoi x00F0icaeyaeax00BAoueny ia iniiax00B3 canoinoaaiiy ax00B3eueo neeaaeieo iiaeaeae oaenox00B3a, ciax00F0aaeaiyue aai x00B3ioeo aeaieo. x00D0icaeyiaii, iaix00F0eeeaae, eieaeueii aaeaioiaaio noaio noeneaiiy Aaioex00B3 oa x00B3i., aea eiaeoaaiiy oa aeaeiaeoaaiiy ix00F0aoethx00BA c N inoaiix00B3ie x00F0x00B3cieie neiaaie. Neiai, ui ciaoiaeeoueny a eao-aooax00F0x00B3, aecia/ax00BAoueny ii oex00B3ei/enaeueiiio x00B3iaeaeno aooax00F0a. Neiai, yea a iueiio ia ciaoiaeeoueny, iax00F0aaeax00BAoueny a eao-aooax00F0 /ax00F0ac iax00F0aneeaiiy eiai iax00F0eax00F0a, yeee eaea ianooiiei ca naieie neiaieaie oeueiai neiaa. Oea /oaeiaa iiaeaeue aeey oaenoo, a yeiio neiaa /anoi aeeix00F0enoiaothoueny ia ix00F0ioycx00B3 aeayeiai eix00F0ioeiai /ano, a iiox00B3i aaea aeiaai ia aeeix00F0enoiaothoueny. x00AFo noaooy iaaiaix00F0thx00BA aeaex00B3eueea eiaeoaaiue cix00B3iii? aeiaaeaie aaea aeey oex00B3ei/enaeueieo x00B3iaeaenx00B3a eao-aooax00F0a. A yeinox00B3 iniiae aeey eiaex00B3a cix00B3iii? aeiaaeeie ax00F0x00B3oiaoe/iee iaoiae aeicaieyx00BA aeeix00F0enoiaoaaoe aoaeue-yea x00F0iciiaex00B3eaiiy eiiax00B3x00F0iinoae, a oiio /enex00B3 nax00F0aae aaaaoueio x00B3ioeo e ox00B3, yex00B3 iaaaaeaix00B3 ooo. Ex00F0x00B3i oiai, ax00B3i aeiioneax00BA aeey x00B3iaeaenx00B3a eao-aooax00F0a canoinoaaiiy aaeaioeaii? iiaeaex00B3, ui x00BA aaaeaiei o aeiaaeeo, eiee x00F0iciiaex00B3eaiiy aeinooix00B3a aei eao-aooax00F0o aaaeeiiax00F0aaeaa/oaaia.

Aeiaeaoie 1. Aeiaaaeaiiy aeaeiaeoth/i? iax00F0x00B3aiinox00B3.

Aaaaeax00BAii:

aai x00B3ioeie neiaaie:

(1).

(inoaiiy iax00F0x00B3aix00B3noue aex00F0aco (1) iioiaeeoue ax00B3ae oiai oaeoo, ui cum_freq[symbol — 1] iiaeiia aooe oex00B3eei). Iiox00B3i ie oi/aii iieacaoe, ui low' (value (high', aea low' i high' x00BA iiiaeaix00B3 cia/aiiy aeey low i high ye oea aecia/aii ieae/a.

(a) low' :

.

oiio low' (value, oiio ui x00B3 value, i low, i cum_freq [0] > 0.

(a) high:

C aex00F0aco (1) iax00BAii:

.

Aeiaeaoie 2. x00D0iai/ee eiae aeey aaeaioeaiiai ax00F0eoiaoe/iiai noeneaiiy.

Arithmetic_coding.h.

/*Iaieioaiiy, iaiaox00B3aeix00B3 aeey ax00F0eoiaoe/iiai*/.

/*eiaeoaaiiy oa aeaeiaeoaaiiy*/.

/*x00B2ioax00F0aae cia/aiue ax00F0eoiaoe/iiai eiaeo*/.

#define Code_value_bits 16.

typedef long code_value;

#define Top_value (((long) 1 << Code_value_bits) — 1).

/*Aeacx00B3aieee ia nax00F0aaeeio x00B3 /aoaax00F0ox00B3 x00B3ioax00F0aaea cia/aiiy eiaeo*/.

#define First_qtr (Top_value/4 + 1).

#define Half (2*First_qtr).

#define Third_qtr (3*First_qtr).

model.h.

/* x00B2ioax00F0oaen c iiaeaeeth */.

/* Iiiaeeia eiaeox00BAieo neiaiex00B3a */.

#define No_of_chars 256.

#define EOF_symbol (No_of_chars + 1).

#define No_of_symbols (No_of_chars + 1).

/* Oaaeeoex00B3 iax00F0aeiaeoaaiiy ii/aoeiaeo oa x00F0iai/eo neiaiex00B3a */.

int char_to_index[No_of_chars];

unsigned char index_to_char[No_of_symbols + 1];

/* Oaaeeoey iaeiie/aieo /anoio */.

#define Max_frequency 16 383.

int cum_freq[No_of_symbols+1];

encode.c.

/* Aieiaia ix00F0ioeaaeox00F0a eiaeoaaiiy */.

#include.

#include «model.h «.

main ().

{ start_model ();

start_outputing_bits ();

start_encoding ();

for (;;) {.

int ch; int symbol;

ch = getc (stdin);

if (ch==EOF) break;

symbol = char_to_index[ch];

encode_symbol (symbol, cum_freq);

update_model (symbol);

}.

encode_symbol (EOF_symbol, cum_freq);

done_encoding ();

done_outputing_bits ();

exit (0);

}.

Arithmetic_encode.c.

/* Aeaix00F0eoi ax00F0eoiaoe/iiai eiaeoaaiiy */.

#include «arithmetic_encoding.h «.

static void bit_plus_follow ();

/* Iioi/iee noai eiaeoaaiiy */.

static code_value low, high;

static long bits_to_follow;

/* Ii/aoie eiaeoaaiiy iioiea neiaiex00B3a */.

start_encoding ().

{ low = 0;

high = Top_value;

bits_to_follow = 0;

}.

/* Eiaeoaaiiy neiaieo */.

encode_symbol (symbol, cum_freq).

int symbol;

int cum_freq[];

{ long range;

range = (long)(high-low)+1;

high = low + (range*cum_freq[symbol-1])/cum_freq[0]-1;

low = low + (range*cum_freq[symbol])/cum_freq[0];

for (;;) {.

if (high.

bit_plus_follow (0);

}.

else if (low>=Half) {.

bit_plus_follow (1);

low -= Half;

high -= Half;

}.

else if (low>=First_qtr && high.

{ bits_to_follow +=1;

low -= First_qtr;

high -= First_qtr;

}.

else break;

low = 2*low;

high = 2*high+1;

}.

}.

/* Caaax00F0oaiiy eiaeoaaiiy iioieo */.

done_encoding ().

{ bits_to_follow += 1;

if (low.

else bit_plus_follow (1);

}.

/* aeaiae ax00B3oa x00F0acii c ianooiieie ca iei, iaax00F0iaieie aei iueiai */.

static void bit_plus_follow (bit).

int bit;

{ output_bit (bit);

while (bits_to_follow>0) {.

output_bit (!bit);

bits_to_follow -= 1;

}.

}.

decode.c.

/* Aieiaia ix00F0ioeaaeox00F0a aeey aeaeiaeoaaiiy */.

#include.

#include «model.h «.

main ().

{ start_model ();

start_inputing_bits ();

start_decoding ();

for (;;) {.

int ch; int symbol;

symbol = decode_symbol (cum_freq);

if (symbol == EOF_symbol) break;

ch = index_to_char[symbol];

putc (ch, stdout);

update_model (symbol);

}.

exit (0);

}.

arithmetic_decode.c.

/* Aeaix00F0eoi ax00F0eoiaoe/iiai aeaeiaeoaaiiy */.

#include «arithmetic_coding.h «.

/* Iioieiaee noai aeaeiaeoaaiiy */.

static code_value value;

static code_value low, high;

/* Ii/aoie aeaeiaeoaaiiy iioiea neiaiex00B3a */.

start_decoding ();

{ int i;

value = 0;

for (i = 1; i<=Code_value_bits; i++) {.

value = 2*value+input_bit ();

}.

low = 0;

high = Top_value;

}.

/* Aeaeiaeoaaiiy ianooiiiai neiaiea */.

int decode_symbol (cum_freq).

int cum_freq[];

long range;

int cum;

int symbol;

range = (long)(high — low)+1;

cum = (((long) (value — low)+1)*cum_freq[0]-1)/range;

for (symbol = 1; cum_freq[symbol]>cum; symbol++);

high = low + (range*cum_freq[symbol-1])/cum_freq[0]-1;

low = low + (range*cum_freq[symbol])/cum_freq[0];

for (;;){.

if (high.

else if (low>=Half).

{.

value -= Half;

low -= Half;

high -= Half;

}.

else if (low>=First_qtr && high.

{.

value -= First_qtr;

low -= First_qtr;

high -= First_qtr;

}.

else break;

low = 2*low;

high = 2*high+1;

}.

return symbol;

}.

bit_input.c.

/* Ix00F0ioeaaeox00F0e aaiaeo ax00B3ox00B3a */.

#include.

#include «arithmetic_coding «.

/* Ax00B3oiaee aooax00F0 */.

static int buffer;

static int bits_to_go;

static int garbage_bits;

/* x00B2ix00B3oex00B3aoex00B3caoex00B3y iiax00B3oiaiai aaiaeo */.

start_inputing_bits ();

{ bits_to_go = 0;

garbage_bits = 0;

}.

/* Aaiae ax00B3oa */.

int input_bit ();

{ int t;

if (bits_to_go==0) {.

buffer = getc (stdin);

if (buffer==EOF) {.

garbage_bits +=1;

if (garbage_bits>Code_value_bits-2) {.

fprintf (stderr, «Bad input file »);

exit (-1);

}.

}.

bits_to_go = 8;

}.

t = buffer&1;

buffer >>= 1;

bits_to_go -= 1;

return t;

}.

bit_output.c.

/* Ix00F0ioeaaeox00F0a aeaiaeo ax00B3ox00B3a */.

#include.

/* Ax00B3oiaee aooax00F0 */.

static int buffer;

static int bits_to_go;

/* x00B2ix00B3oex00B3aex00B3caoex00B3y ax00B3oiaiai aooax00F0a */.

start_outputing_bits ().

{ buffer = 0;

bits_to_go = 8;

}.

/* Aeax00B3ae ax00B3oa */.

output_bit (bit).

int bit;

{ buffer >>=1;

if (bit) buffer |= 0×80;

bits_to_go -= 1;

if (bits_to_go==0) {.

putc (buffer, stdout);

bits_to_go = 8;

}.

}.

/* Aeieaaiiy inoaiix00B3o ax00B3ox00B3a */.

done_outputing_bits ().

{ putc (buffer>>bits_to_go, stdout);

}.

adaptive_model.c.

/* Iiaeaeue c aaeaioeaiei aeaeax00F0aeii */.

#include «model.h «.

int freq[No_of_symbols+1];

/* x00B2ix00B3oex00B3aex00B3caoex00B3y iiaeaex00B3 */.

start_model ().

{ int i;

for (i = 0; i.

char_to_index[i] = i+1;

index_to_char[i+1] = i;

}.

for (i = 0; i.

freq[i] = 1;

cum_freq[i] = No_of_symbols — i;

}.

freq[0] = 0;

/* Iiiaeaiiy iiaeaex00B3 o ax00B3aeiiax00B3aeiinox00B3 c iiaei neiaieii */.

update_model (symbol).

int symbol;

{ int i;

if (cum_freq[0]==Max_frequency) {.

int cum;

cum = 0;

for (i = No_of_symbols; i>=0; i—) {.

freq[i] = (freq[i]+1)/2;

cum_freq[i] = cum;

cum += freq[i];

}.

}.

for (i = symbol; freq[i]==freq[i-1]; i—);

if (i.

int ch_i, ch_symbol;

ch_i = index_to_char[i];

ch_symbol = index_to_char[symbol];

index_to_char[i] = ch_symbol;

index_to_char[symbol] = ch_i;

char_to_index[ch_i] = symbol;

char_to_index[ch_symbol] = i;

}.

freq[i] += 1;

while (i>0) {.

i -= 1;

cum_freq[i] += 1;

}.

}.

Ex00B3oax00F0aoox00F0a.

Rubin F. Arithmetic stream coding using fixed precision registers, IEEE Transactions IT-25, #6, Nov79, pp. 672 — 675.

Ex00F0e/aaneee x00D0. A. Naeaoea e iiene eioix00F0iaoeee., Iineaa, 1989 a.

Eioiaithe Ae. Naeaoea eioix00F0iaoeee: eae yoi aeaeaaoueny., IndexPRO, Eeaa, x00B9x00B91,2.

PAGE 3.

Показати весь текст
Заповнити форму поточною роботою