home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: SHell self-extracting ARchive
(archive/shar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/329 Shell Archive Format
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 6d 69 73 63 0a 50 61 |.sources|.misc.Pa|
|00000020| 74 68 3a 20 73 70 61 72 | 6b 79 21 6b 65 6e 74 0a |th: spar|ky!kent.|
|00000030| 46 72 6f 6d 3a 20 6a 70 | 65 67 2d 69 6e 66 6f 40 |From: jp|eg-info@|
|00000040| 75 75 6e 65 74 2e 75 75 | 2e 6e 65 74 20 28 49 6e |uunet.uu|.net (In|
|00000050| 64 65 70 65 6e 64 65 6e | 74 20 4a 50 45 47 20 47 |dependen|t JPEG G|
|00000060| 72 6f 75 70 29 0a 53 75 | 62 6a 65 63 74 3a 20 20 |roup).Su|bject: |
|00000070| 76 33 34 69 30 35 37 3a | 20 20 6a 70 65 67 20 2d |v34i057:| jpeg -|
|00000080| 20 4a 50 45 47 20 69 6d | 61 67 65 20 63 6f 6d 70 | JPEG im|age comp|
|00000090| 72 65 73 73 69 6f 6e 2c | 20 50 61 72 74 30 33 2f |ression,| Part03/|
|000000a0| 31 38 0a 4d 65 73 73 61 | 67 65 2d 49 44 3a 20 3c |18.Messa|ge-ID: <|
|000000b0| 31 39 39 32 44 65 63 31 | 37 2e 30 34 31 36 30 39 |1992Dec1|7.041609|
|000000c0| 2e 32 33 32 33 33 40 73 | 70 61 72 6b 79 2e 69 6d |.23233@s|parky.im|
|000000d0| 64 2e 73 74 65 72 6c 69 | 6e 67 2e 63 6f 6d 3e 0a |d.sterli|ng.com>.|
|000000e0| 46 6f 6c 6c 6f 77 75 70 | 2d 54 6f 3a 20 63 6f 6d |Followup|-To: com|
|000000f0| 70 2e 73 6f 75 72 63 65 | 73 2e 64 0a 58 2d 4d 64 |p.source|s.d.X-Md|
|00000100| 34 2d 53 69 67 6e 61 74 | 75 72 65 3a 20 39 66 38 |4-Signat|ure: 9f8|
|00000110| 64 32 65 31 37 62 61 64 | 37 35 62 31 34 64 30 33 |d2e17bad|75b14d03|
|00000120| 64 31 35 61 64 35 30 65 | 65 39 66 38 38 0a 53 65 |d15ad50e|e9f88.Se|
|00000130| 6e 64 65 72 3a 20 6b 65 | 6e 74 40 73 70 61 72 6b |nder: ke|nt@spark|
|00000140| 79 2e 69 6d 64 2e 73 74 | 65 72 6c 69 6e 67 2e 63 |y.imd.st|erling.c|
|00000150| 6f 6d 20 28 4b 65 6e 74 | 20 4c 61 6e 64 66 69 65 |om (Kent| Landfie|
|00000160| 6c 64 29 0a 4f 72 67 61 | 6e 69 7a 61 74 69 6f 6e |ld).Orga|nization|
|00000170| 3a 20 53 74 65 72 6c 69 | 6e 67 20 53 6f 66 74 77 |: Sterli|ng Softw|
|00000180| 61 72 65 0a 52 65 66 65 | 72 65 6e 63 65 73 3a 20 |are.Refe|rences: |
|00000190| 3c 63 73 6d 2d 76 33 34 | 69 30 35 35 3d 6a 70 65 |<csm-v34|i055=jpe|
|000001a0| 67 2e 32 32 30 34 32 34 | 40 73 70 61 72 6b 79 2e |g.220424|@sparky.|
|000001b0| 49 4d 44 2e 53 74 65 72 | 6c 69 6e 67 2e 43 4f 4d |IMD.Ster|ling.COM|
|000001c0| 3e 0a 44 61 74 65 3a 20 | 54 68 75 2c 20 31 37 20 |>.Date: |Thu, 17 |
|000001d0| 44 65 63 20 31 39 39 32 | 20 30 34 3a 31 36 3a 30 |Dec 1992| 04:16:0|
|000001e0| 39 20 47 4d 54 0a 41 70 | 70 72 6f 76 65 64 3a 20 |9 GMT.Ap|proved: |
|000001f0| 6b 65 6e 74 40 73 70 61 | 72 6b 79 2e 69 6d 64 2e |kent@spa|rky.imd.|
|00000200| 73 74 65 72 6c 69 6e 67 | 2e 63 6f 6d 0a 4c 69 6e |sterling|.com.Lin|
|00000210| 65 73 3a 20 31 31 37 31 | 0a 0a 53 75 62 6d 69 74 |es: 1171|..Submit|
|00000220| 74 65 64 2d 62 79 3a 20 | 6a 70 65 67 2d 69 6e 66 |ted-by: |jpeg-inf|
|00000230| 6f 40 75 75 6e 65 74 2e | 75 75 2e 6e 65 74 20 28 |o@uunet.|uu.net (|
|00000240| 49 6e 64 65 70 65 6e 64 | 65 6e 74 20 4a 50 45 47 |Independ|ent JPEG|
|00000250| 20 47 72 6f 75 70 29 0a | 50 6f 73 74 69 6e 67 2d | Group).|Posting-|
|00000260| 6e 75 6d 62 65 72 3a 20 | 56 6f 6c 75 6d 65 20 33 |number: |Volume 3|
|00000270| 34 2c 20 49 73 73 75 65 | 20 35 37 0a 41 72 63 68 |4, Issue| 57.Arch|
|00000280| 69 76 65 2d 6e 61 6d 65 | 3a 20 6a 70 65 67 2f 70 |ive-name|: jpeg/p|
|00000290| 61 72 74 30 33 0a 45 6e | 76 69 72 6f 6e 6d 65 6e |art03.En|vironmen|
|000002a0| 74 3a 20 55 4e 49 58 2c | 20 56 4d 53 2c 20 4d 53 |t: UNIX,| VMS, MS|
|000002b0| 2d 44 4f 53 2c 20 4d 61 | 63 2c 20 41 6d 69 67 61 |-DOS, Ma|c, Amiga|
|000002c0| 2c 20 41 74 61 72 69 2c | 20 43 72 61 79 0a 53 75 |, Atari,| Cray.Su|
|000002d0| 70 65 72 73 65 64 65 73 | 3a 20 6a 70 65 67 3a 20 |persedes|: jpeg: |
|000002e0| 56 6f 6c 75 6d 65 20 32 | 39 2c 20 49 73 73 75 65 |Volume 2|9, Issue|
|000002f0| 20 31 2d 31 38 0a 0a 23 | 21 20 2f 62 69 6e 2f 73 | 1-18..#|! /bin/s|
|00000300| 68 0a 23 20 54 68 69 73 | 20 69 73 20 61 20 73 68 |h.# This| is a sh|
|00000310| 65 6c 6c 20 61 72 63 68 | 69 76 65 2e 20 20 52 65 |ell arch|ive. Re|
|00000320| 6d 6f 76 65 20 61 6e 79 | 74 68 69 6e 67 20 62 65 |move any|thing be|
|00000330| 66 6f 72 65 20 74 68 69 | 73 20 6c 69 6e 65 2c 20 |fore thi|s line, |
|00000340| 74 68 65 6e 20 66 65 65 | 64 20 69 74 0a 23 20 69 |then fee|d it.# i|
|00000350| 6e 74 6f 20 61 20 73 68 | 65 6c 6c 20 76 69 61 20 |nto a sh|ell via |
|00000360| 22 73 68 20 66 69 6c 65 | 22 20 6f 72 20 73 69 6d |"sh file|" or sim|
|00000370| 69 6c 61 72 2e 20 20 54 | 6f 20 6f 76 65 72 77 72 |ilar. T|o overwr|
|00000380| 69 74 65 20 65 78 69 73 | 74 69 6e 67 20 66 69 6c |ite exis|ting fil|
|00000390| 65 73 2c 0a 23 20 74 79 | 70 65 20 22 73 68 20 66 |es,.# ty|pe "sh f|
|000003a0| 69 6c 65 20 2d 63 22 2e | 0a 23 20 43 6f 6e 74 65 |ile -c".|.# Conte|
|000003b0| 6e 74 73 3a 20 20 61 72 | 63 68 69 74 65 63 74 75 |nts: ar|chitectu|
|000003c0| 72 65 2e 42 20 6a 63 64 | 65 66 6c 74 73 2e 63 20 |re.B jcd|eflts.c |
|000003d0| 6a 76 65 72 73 69 6f 6e | 2e 68 0a 23 20 57 72 61 |jversion|.h.# Wra|
|000003e0| 70 70 65 64 20 62 79 20 | 6b 65 6e 74 40 73 70 61 |pped by |kent@spa|
|000003f0| 72 6b 79 20 6f 6e 20 57 | 65 64 20 44 65 63 20 31 |rky on W|ed Dec 1|
|00000400| 36 20 32 30 3a 35 32 3a | 32 35 20 31 39 39 32 0a |6 20:52:|25 1992.|
|00000410| 50 41 54 48 3d 2f 62 69 | 6e 3a 2f 75 73 72 2f 62 |PATH=/bi|n:/usr/b|
|00000420| 69 6e 3a 2f 75 73 72 2f | 75 63 62 3a 2f 75 73 72 |in:/usr/|ucb:/usr|
|00000430| 2f 6c 6f 63 61 6c 2f 62 | 69 6e 3a 2f 75 73 72 2f |/local/b|in:/usr/|
|00000440| 6c 62 69 6e 20 3b 20 65 | 78 70 6f 72 74 20 50 41 |lbin ; e|xport PA|
|00000450| 54 48 0a 65 63 68 6f 20 | 49 66 20 74 68 69 73 20 |TH.echo |If this |
|00000460| 61 72 63 68 69 76 65 20 | 69 73 20 63 6f 6d 70 6c |archive |is compl|
|00000470| 65 74 65 2c 20 79 6f 75 | 20 77 69 6c 6c 20 73 65 |ete, you| will se|
|00000480| 65 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |e the fo|llowing |
|00000490| 6d 65 73 73 61 67 65 3a | 0a 65 63 68 6f 20 27 20 |message:|.echo ' |
|000004a0| 20 20 20 20 20 20 20 20 | 20 22 73 68 61 72 3a 20 | | "shar: |
|000004b0| 45 6e 64 20 6f 66 20 61 | 72 63 68 69 76 65 20 33 |End of a|rchive 3|
|000004c0| 20 28 6f 66 20 31 38 29 | 2e 22 27 0a 69 66 20 74 | (of 18)|."'.if t|
|000004d0| 65 73 74 20 2d 66 20 27 | 61 72 63 68 69 74 65 63 |est -f '|architec|
|000004e0| 74 75 72 65 2e 42 27 20 | 2d 61 20 22 24 7b 31 7d |ture.B' |-a "${1}|
|000004f0| 22 20 21 3d 20 22 2d 63 | 22 20 3b 20 74 68 65 6e |" != "-c|" ; then|
|00000500| 20 0a 20 20 65 63 68 6f | 20 73 68 61 72 3a 20 57 | . echo| shar: W|
|00000510| 69 6c 6c 20 6e 6f 74 20 | 63 6c 6f 62 62 65 72 20 |ill not |clobber |
|00000520| 65 78 69 73 74 69 6e 67 | 20 66 69 6c 65 20 5c 22 |existing| file \"|
|00000530| 27 61 72 63 68 69 74 65 | 63 74 75 72 65 2e 42 27 |'archite|cture.B'|
|00000540| 5c 22 0a 65 6c 73 65 0a | 20 20 65 63 68 6f 20 73 |\".else.| echo s|
|00000550| 68 61 72 3a 20 45 78 74 | 72 61 63 74 69 6e 67 20 |har: Ext|racting |
|00000560| 5c 22 27 61 72 63 68 69 | 74 65 63 74 75 72 65 2e |\"'archi|tecture.|
|00000570| 42 27 5c 22 20 5c 28 34 | 30 34 36 31 20 63 68 61 |B'\" \(4|0461 cha|
|00000580| 72 61 63 74 65 72 73 5c | 29 0a 20 20 73 65 64 20 |racters\|). sed |
|00000590| 22 73 2f 5e 58 2f 2f 22 | 20 3e 27 61 72 63 68 69 |"s/^X//"| >'archi|
|000005a0| 74 65 63 74 75 72 65 2e | 42 27 20 3c 3c 27 45 4e |tecture.|B' <<'EN|
|000005b0| 44 5f 4f 46 5f 46 49 4c | 45 27 0a 58 0a 58 46 6f |D_OF_FIL|E'.X.XFo|
|000005c0| 72 20 73 69 6d 69 6c 61 | 72 20 72 65 61 73 6f 6e |r simila|r reason|
|000005d0| 73 2c 20 6f 6e 65 20 4d | 43 55 20 69 73 20 61 6c |s, one M|CU is al|
|000005e0| 73 6f 20 74 68 65 20 62 | 65 73 74 20 63 68 75 6e |so the b|est chun|
|000005f0| 6b 20 73 69 7a 65 20 66 | 6f 72 20 74 68 65 20 66 |k size f|or the f|
|00000600| 72 65 71 75 65 6e 63 79 | 0a 58 63 6f 65 66 66 69 |requency|.Xcoeffi|
|00000610| 63 69 65 6e 74 20 71 75 | 61 6e 74 69 7a 61 74 69 |cient qu|antizati|
|00000620| 6f 6e 20 61 6e 64 20 64 | 65 71 75 61 6e 74 69 7a |on and d|equantiz|
|00000630| 61 74 69 6f 6e 20 73 74 | 65 70 73 2e 0a 58 0a 58 |ation st|eps..X.X|
|00000640| 46 6f 72 20 64 6f 77 6e | 73 61 6d 70 6c 69 6e 67 |For down|sampling|
|00000650| 20 61 6e 64 20 75 70 73 | 61 6d 70 6c 69 6e 67 2c | and ups|ampling,|
|00000660| 20 74 68 65 20 62 65 73 | 74 20 63 68 75 6e 6b 20 | the bes|t chunk |
|00000670| 73 69 7a 65 20 69 73 20 | 74 6f 20 68 61 76 65 20 |size is |to have |
|00000680| 65 61 63 68 20 63 61 6c | 6c 0a 58 74 72 61 6e 73 |each cal|l.Xtrans|
|00000690| 66 6f 72 6d 20 56 6b 20 | 73 61 6d 70 6c 65 20 72 |form Vk |sample r|
|000006a0| 6f 77 73 20 66 72 6f 6d | 20 6f 72 20 74 6f 20 56 |ows from| or to V|
|000006b0| 6d 61 78 20 73 61 6d 70 | 6c 65 20 72 6f 77 73 20 |max samp|le rows |
|000006c0| 28 56 6b 20 3d 20 74 68 | 69 73 20 63 6f 6d 70 6f |(Vk = th|is compo|
|000006d0| 6e 65 6e 74 27 73 0a 58 | 76 65 72 74 69 63 61 6c |nent's.X|vertical|
|000006e0| 20 73 61 6d 70 6c 69 6e | 67 20 66 61 63 74 6f 72 | samplin|g factor|
|000006f0| 2c 20 56 6d 61 78 20 3d | 20 6c 61 72 67 65 73 74 |, Vmax =| largest|
|00000700| 20 76 65 72 74 69 63 61 | 6c 20 73 61 6d 70 6c 69 | vertica|l sampli|
|00000710| 6e 67 20 66 61 63 74 6f | 72 29 2e 20 20 54 68 65 |ng facto|r). The|
|00000720| 72 65 20 61 72 65 0a 58 | 65 69 67 68 74 20 73 75 |re are.X|eight su|
|00000730| 63 68 20 63 68 75 6e 6b | 73 20 69 6e 20 65 61 63 |ch chunk|s in eac|
|00000740| 68 20 4d 43 55 20 72 6f | 77 2e 20 20 55 73 69 6e |h MCU ro|w. Usin|
|00000750| 67 20 61 20 77 68 6f 6c | 65 20 4d 43 55 20 72 6f |g a whol|e MCU ro|
|00000760| 77 20 61 73 20 74 68 65 | 20 63 68 75 6e 6b 20 73 |w as the| chunk s|
|00000770| 69 7a 65 0a 58 77 6f 75 | 6c 64 20 72 65 64 75 63 |ize.Xwou|ld reduc|
|00000780| 65 20 66 75 6e 63 74 69 | 6f 6e 20 63 61 6c 6c 20 |e functi|on call |
|00000790| 6f 76 65 72 68 65 61 64 | 20 61 20 66 72 61 63 74 |overhead| a fract|
|000007a0| 69 6f 6e 2c 20 62 75 74 | 20 77 6f 75 6c 64 20 69 |ion, but| would i|
|000007b0| 6d 70 6c 79 20 6d 6f 72 | 65 20 62 75 66 66 65 72 |mply mor|e buffer|
|000007c0| 69 6e 67 0a 58 74 6f 20 | 70 72 6f 76 69 64 65 20 |ing.Xto |provide |
|000007d0| 63 6f 6e 74 65 78 74 20 | 66 6f 72 20 63 72 6f 73 |context |for cros|
|000007e0| 73 2d 70 69 78 65 6c 20 | 73 6d 6f 6f 74 68 69 6e |s-pixel |smoothin|
|000007f0| 67 2e 0a 58 0a 58 0a 58 | 2a 2a 2a 20 43 6f 6d 70 |g..X.X.X|*** Comp|
|00000800| 72 65 73 73 69 6f 6e 20 | 6f 62 6a 65 63 74 20 73 |ression |object s|
|00000810| 74 72 75 63 74 75 72 65 | 20 2a 2a 2a 0a 58 0a 58 |tructure| ***.X.X|
|00000820| 49 20 70 72 6f 70 6f 73 | 65 20 74 68 65 20 66 6f |I propos|e the fo|
|00000830| 6c 6c 6f 77 69 6e 67 20 | 73 65 74 20 6f 66 20 6f |llowing |set of o|
|00000840| 62 6a 65 63 74 73 20 66 | 6f 72 20 74 68 65 20 63 |bjects f|or the c|
|00000850| 6f 6d 70 72 65 73 73 6f | 72 2e 20 20 48 65 72 65 |ompresso|r. Here|
|00000860| 20 61 6e 20 22 6f 62 6a | 65 63 74 22 0a 58 69 73 | an "obj|ect".Xis|
|00000870| 20 74 68 65 20 63 6f 6d | 6d 6f 6e 20 69 6e 74 65 | the com|mon inte|
|00000880| 72 66 61 63 65 20 66 6f | 72 20 6f 6e 65 20 6f 72 |rface fo|r one or|
|00000890| 20 6d 6f 72 65 20 6d 6f | 64 75 6c 65 73 20 68 61 | more mo|dules ha|
|000008a0| 76 69 6e 67 20 63 6f 6d | 70 61 72 61 62 6c 65 20 |ving com|parable |
|000008b0| 66 75 6e 63 74 69 6f 6e | 73 2e 0a 58 0a 58 4d 6f |function|s..X.XMo|
|000008c0| 73 74 20 6f 66 20 74 68 | 65 73 65 20 6f 62 6a 65 |st of th|ese obje|
|000008d0| 63 74 73 20 63 61 6e 20 | 62 65 20 6a 75 73 74 69 |cts can |be justi|
|000008e0| 66 69 65 64 20 61 73 20 | 69 6e 66 6f 72 6d 61 74 |fied as |informat|
|000008f0| 69 6f 6e 2d 68 69 64 69 | 6e 67 20 6d 6f 64 75 6c |ion-hidi|ng modul|
|00000900| 65 73 2e 0a 58 49 27 76 | 65 20 69 6e 64 69 63 61 |es..XI'v|e indica|
|00000910| 74 65 64 20 77 68 61 74 | 20 69 6e 66 6f 72 6d 61 |ted what| informa|
|00000920| 74 69 6f 6e 20 69 73 20 | 70 72 69 76 61 74 65 20 |tion is |private |
|00000930| 74 6f 20 65 61 63 68 20 | 6f 62 6a 65 63 74 2f 6d |to each |object/m|
|00000940| 6f 64 75 6c 65 2e 0a 58 | 0a 58 4e 6f 74 65 20 74 |odule..X|.XNote t|
|00000950| 68 61 74 20 69 6e 20 61 | 6c 6c 20 63 61 73 65 73 |hat in a|ll cases|
|00000960| 2c 20 74 68 65 20 63 61 | 6c 6c 65 72 20 6f 66 20 |, the ca|ller of |
|00000970| 61 20 6d 65 74 68 6f 64 | 20 69 73 20 65 78 70 65 |a method| is expe|
|00000980| 63 74 65 64 20 74 6f 20 | 68 61 76 65 20 61 6c 6c |cted to |have all|
|00000990| 6f 63 61 74 65 64 0a 58 | 61 6e 79 20 73 74 6f 72 |ocated.X|any stor|
|000009a0| 61 67 65 20 6e 65 65 64 | 65 64 20 66 6f 72 20 69 |age need|ed for i|
|000009b0| 74 20 74 6f 20 72 65 74 | 75 72 6e 20 69 74 73 20 |t to ret|urn its |
|000009c0| 72 65 73 75 6c 74 2e 20 | 20 28 54 79 70 69 63 61 |result. | (Typica|
|000009d0| 6c 6c 79 20 74 68 69 73 | 20 73 74 6f 72 61 67 65 |lly this| storage|
|000009e0| 20 63 61 6e 0a 58 62 65 | 20 72 65 2d 75 73 65 64 | can.Xbe| re-used|
|000009f0| 20 69 6e 20 73 75 63 63 | 65 73 73 69 76 65 20 63 | in succ|essive c|
|00000a00| 61 6c 6c 73 2c 20 73 6f | 20 6d 61 6c 6c 6f 63 27 |alls, so| malloc'|
|00000a10| 69 6e 67 20 61 6e 64 20 | 66 72 65 65 27 69 6e 67 |ing and |free'ing|
|00000a20| 20 6f 6e 63 65 20 70 65 | 72 20 63 61 6c 6c 20 69 | once pe|r call i|
|00000a30| 73 0a 58 6e 6f 74 20 72 | 65 61 73 6f 6e 61 62 6c |s.Xnot r|easonabl|
|00000a40| 65 2e 29 20 20 41 6c 73 | 6f 2c 20 6d 75 63 68 20 |e.) Als|o, much |
|00000a50| 6f 66 20 74 68 65 20 63 | 6f 6e 74 65 78 74 20 72 |of the c|ontext r|
|00000a60| 65 71 75 69 72 65 64 20 | 28 63 6f 6d 70 72 65 73 |equired |(compres|
|00000a70| 73 69 6f 6e 20 70 61 72 | 61 6d 65 74 65 72 73 2c |sion par|ameters,|
|00000a80| 0a 58 69 6d 61 67 65 20 | 73 69 7a 65 2c 20 65 74 |.Ximage |size, et|
|00000a90| 63 29 20 77 69 6c 6c 20 | 62 65 20 70 61 73 73 65 |c) will |be passe|
|00000aa0| 64 20 61 72 6f 75 6e 64 | 20 69 6e 20 6c 61 72 67 |d around| in larg|
|00000ab0| 65 20 63 6f 6d 6d 6f 6e | 20 64 61 74 61 20 73 74 |e common| data st|
|00000ac0| 72 75 63 74 75 72 65 73 | 2c 20 77 68 69 63 68 0a |ructures|, which.|
|00000ad0| 58 61 72 65 6e 27 74 20 | 64 65 73 63 72 69 62 65 |Xaren't |describe|
|00000ae0| 64 20 68 65 72 65 3b 20 | 73 65 65 20 74 68 65 20 |d here; |see the |
|00000af0| 68 65 61 64 65 72 20 66 | 69 6c 65 73 2e 20 20 4e |header f|iles. N|
|00000b00| 6f 74 69 63 65 20 74 68 | 61 74 20 61 6e 79 20 6f |otice th|at any o|
|00000b10| 62 6a 65 63 74 20 74 68 | 61 74 0a 58 6d 69 67 68 |bject th|at.Xmigh|
|00000b20| 74 20 6e 65 65 64 20 74 | 6f 20 61 6c 6c 6f 63 61 |t need t|o alloca|
|00000b30| 74 65 20 77 6f 72 6b 69 | 6e 67 20 73 74 6f 72 61 |te worki|ng stora|
|00000b40| 67 65 20 72 65 63 65 69 | 76 65 73 20 61 6e 20 22 |ge recei|ves an "|
|00000b50| 69 6e 69 74 22 20 61 6e | 64 20 61 20 22 74 65 72 |init" an|d a "ter|
|00000b60| 6d 22 20 63 61 6c 6c 3b | 0a 58 22 74 65 72 6d 22 |m" call;|.X"term"|
|00000b70| 20 73 68 6f 75 6c 64 20 | 62 65 20 63 61 72 65 66 | should |be caref|
|00000b80| 75 6c 20 74 6f 20 66 72 | 65 65 20 61 6c 6c 20 61 |ul to fr|ee all a|
|00000b90| 6c 6c 6f 63 61 74 65 64 | 20 73 74 6f 72 61 67 65 |llocated| storage|
|00000ba0| 20 73 6f 20 74 68 61 74 | 20 74 68 65 20 4a 50 45 | so that| the JPE|
|00000bb0| 47 20 73 79 73 74 65 6d | 0a 58 63 61 6e 20 62 65 |G system|.Xcan be|
|00000bc0| 20 75 73 65 64 20 6d 75 | 6c 74 69 70 6c 65 20 74 | used mu|ltiple t|
|00000bd0| 69 6d 65 73 20 64 75 72 | 69 6e 67 20 61 20 70 72 |imes dur|ing a pr|
|00000be0| 6f 67 72 61 6d 20 72 75 | 6e 2e 20 20 28 46 6f 72 |ogram ru|n. (For|
|00000bf0| 20 74 68 65 20 73 61 6d | 65 20 72 65 61 73 6f 6e | the sam|e reason|
|00000c00| 2c 0a 58 64 65 70 65 6e | 64 69 6e 67 20 6f 6e 20 |,.Xdepen|ding on |
|00000c10| 73 74 61 74 69 63 20 69 | 6e 69 74 69 61 6c 69 7a |static i|nitializ|
|00000c20| 61 74 69 6f 6e 20 6f 66 | 20 76 61 72 69 61 62 6c |ation of| variabl|
|00000c30| 65 73 20 69 73 20 61 20 | 6e 6f 2d 6e 6f 2e 20 20 |es is a |no-no. |
|00000c40| 54 68 65 20 6f 6e 6c 79 | 0a 58 65 78 63 65 70 74 |The only|.Xexcept|
|00000c50| 69 6f 6e 20 74 6f 20 74 | 68 65 20 66 72 65 65 2d |ion to t|he free-|
|00000c60| 61 6c 6c 2d 61 6c 6c 6f | 63 61 74 65 64 2d 73 74 |all-allo|cated-st|
|00000c70| 6f 72 61 67 65 20 72 75 | 6c 65 20 69 73 20 74 68 |orage ru|le is th|
|00000c80| 61 74 20 73 74 6f 72 61 | 67 65 20 61 6c 6c 6f 63 |at stora|ge alloc|
|00000c90| 61 74 65 64 20 66 6f 72 | 0a 58 74 68 65 20 65 6e |ated for|.Xthe en|
|00000ca0| 74 69 72 65 20 70 72 6f | 63 65 73 73 69 6e 67 20 |tire pro|cessing |
|00000cb0| 6f 66 20 61 6e 20 69 6d | 61 67 65 20 6e 65 65 64 |of an im|age need|
|00000cc0| 20 6e 6f 74 20 62 65 20 | 65 78 70 6c 69 63 69 74 | not be |explicit|
|00000cd0| 6c 79 20 66 72 65 65 64 | 2c 20 73 69 6e 63 65 20 |ly freed|, since |
|00000ce0| 74 68 65 0a 58 6d 65 6d | 6f 72 79 20 6d 61 6e 61 |the.Xmem|ory mana|
|00000cf0| 67 65 72 27 73 20 66 72 | 65 65 5f 61 6c 6c 20 63 |ger's fr|ee_all c|
|00000d00| 6c 65 61 6e 75 70 20 77 | 69 6c 6c 20 66 72 65 65 |leanup w|ill free|
|00000d10| 20 69 74 2e 29 0a 58 0a | 58 31 2e 20 49 6e 70 75 | it.).X.|X1. Inpu|
|00000d20| 74 20 66 69 6c 65 20 63 | 6f 6e 76 65 72 73 69 6f |t file c|onversio|
|00000d30| 6e 20 74 6f 20 73 74 61 | 6e 64 61 72 64 69 7a 65 |n to sta|ndardize|
|00000d40| 64 20 66 6f 72 6d 2e 20 | 20 54 68 69 73 20 70 72 |d form. | This pr|
|00000d50| 6f 76 69 64 65 73 20 74 | 68 65 73 65 20 6d 65 74 |ovides t|hese met|
|00000d60| 68 6f 64 73 3a 0a 58 09 | 69 6e 70 75 74 5f 69 6e |hods:.X.|input_in|
|00000d70| 69 74 3a 20 72 65 61 64 | 20 74 68 65 20 66 69 6c |it: read| the fil|
|00000d80| 65 20 68 65 61 64 65 72 | 2c 20 72 65 70 6f 72 74 |e header|, report|
|00000d90| 20 69 6d 61 67 65 20 73 | 69 7a 65 20 26 20 63 6f | image s|ize & co|
|00000da0| 6d 70 6f 6e 65 6e 74 20 | 63 6f 75 6e 74 2e 0a 58 |mponent |count..X|
|00000db0| 09 67 65 74 5f 69 6e 70 | 75 74 5f 72 6f 77 3a 20 |.get_inp|ut_row: |
|00000dc0| 72 65 61 64 20 6f 6e 65 | 20 70 69 78 65 6c 20 72 |read one| pixel r|
|00000dd0| 6f 77 2c 20 72 65 74 75 | 72 6e 20 69 74 20 69 6e |ow, retu|rn it in|
|00000de0| 20 6f 75 72 20 73 74 61 | 6e 64 61 72 64 20 66 6f | our sta|ndard fo|
|00000df0| 72 6d 61 74 2e 0a 58 09 | 69 6e 70 75 74 5f 74 65 |rmat..X.|input_te|
|00000e00| 72 6d 3a 20 66 69 6e 69 | 73 68 20 75 70 20 61 74 |rm: fini|sh up at|
|00000e10| 20 74 68 65 20 65 6e 64 | 2e 0a 58 20 20 20 49 6e | the end|..X In|
|00000e20| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 73 | impleme|ntations|
|00000e30| 20 74 68 61 74 20 73 75 | 70 70 6f 72 74 20 6d 75 | that su|pport mu|
|00000e40| 6c 74 69 70 6c 65 20 69 | 6e 70 75 74 20 66 6f 72 |ltiple i|nput for|
|00000e50| 6d 61 74 73 2c 20 69 6e | 70 75 74 5f 69 6e 69 74 |mats, in|put_init|
|00000e60| 20 63 6f 75 6c 64 0a 58 | 20 20 20 73 65 74 20 75 | could.X| set u|
|00000e70| 70 20 61 6e 20 61 70 70 | 72 6f 70 72 69 61 74 65 |p an app|ropriate|
|00000e80| 20 67 65 74 5f 69 6e 70 | 75 74 5f 72 6f 77 20 6d | get_inp|ut_row m|
|00000e90| 65 74 68 6f 64 20 64 65 | 70 65 6e 64 69 6e 67 20 |ethod de|pending |
|00000ea0| 6f 6e 20 74 68 65 20 66 | 6f 72 6d 61 74 20 69 74 |on the f|ormat it|
|00000eb0| 0a 58 20 20 20 66 69 6e | 64 73 2e 20 20 4e 6f 74 |.X fin|ds. Not|
|00000ec0| 65 20 74 68 61 74 20 69 | 6e 20 6d 6f 73 74 20 61 |e that i|n most a|
|00000ed0| 70 70 6c 69 63 61 74 69 | 6f 6e 73 2c 20 74 68 65 |pplicati|ons, the|
|00000ee0| 20 73 65 6c 65 63 74 69 | 6f 6e 20 61 6e 64 20 6f | selecti|on and o|
|00000ef0| 70 65 6e 69 6e 67 20 6f | 66 20 74 68 65 0a 58 20 |pening o|f the.X |
|00000f00| 20 20 69 6e 70 75 74 20 | 66 69 6c 65 20 77 69 6c | input |file wil|
|00000f10| 6c 20 62 65 20 75 6e 64 | 65 72 20 74 68 65 20 63 |l be und|er the c|
|00000f20| 6f 6e 74 72 6f 6c 20 6f | 66 20 74 68 65 20 75 73 |ontrol o|f the us|
|00000f30| 65 72 20 69 6e 74 65 72 | 66 61 63 65 20 6d 6f 64 |er inter|face mod|
|00000f40| 75 6c 65 3b 20 61 6e 64 | 0a 58 20 20 20 69 6e 64 |ule; and|.X ind|
|00000f50| 65 65 64 20 74 68 65 20 | 75 73 65 72 20 69 6e 74 |eed the |user int|
|00000f60| 65 72 66 61 63 65 20 6d | 61 79 20 68 61 76 65 20 |erface m|ay have |
|00000f70| 61 6c 72 65 61 64 79 20 | 72 65 61 64 20 74 68 65 |already |read the|
|00000f80| 20 69 6e 70 75 74 20 68 | 65 61 64 65 72 2c 20 73 | input h|eader, s|
|00000f90| 6f 20 74 68 61 74 0a 58 | 20 20 20 61 6c 6c 20 74 |o that.X| all t|
|00000fa0| 68 61 74 20 69 6e 70 75 | 74 5f 69 6e 69 74 20 6d |hat inpu|t_init m|
|00000fb0| 61 79 20 68 61 76 65 20 | 74 6f 20 64 6f 20 69 73 |ay have |to do is|
|00000fc0| 20 72 65 74 75 72 6e 20 | 70 72 65 76 69 6f 75 73 | return |previous|
|00000fd0| 6c 79 20 73 61 76 65 64 | 20 76 61 6c 75 65 73 2e |ly saved| values.|
|00000fe0| 20 20 54 68 65 0a 58 20 | 20 20 62 65 68 69 6e 64 | The.X | behind|
|00000ff0| 2d 74 68 65 2d 73 63 65 | 6e 65 73 20 69 6e 74 65 |-the-sce|nes inte|
|00001000| 72 61 63 74 69 6f 6e 20 | 62 65 74 77 65 65 6e 20 |raction |between |
|00001010| 74 68 69 73 20 6f 62 6a | 65 63 74 20 61 6e 64 20 |this obj|ect and |
|00001020| 74 68 65 20 75 73 65 72 | 20 69 6e 74 65 72 66 61 |the user| interfa|
|00001030| 63 65 20 69 73 0a 58 20 | 20 20 6e 6f 74 20 73 70 |ce is.X | not sp|
|00001040| 65 63 69 66 69 65 64 20 | 62 79 20 74 68 69 73 20 |ecified |by this |
|00001050| 61 72 63 68 69 74 65 63 | 74 75 72 65 2e 0a 58 20 |architec|ture..X |
|00001060| 20 20 28 48 69 64 65 73 | 20 66 6f 72 6d 61 74 20 | (Hides| format |
|00001070| 6f 66 20 69 6e 70 75 74 | 20 69 6d 61 67 65 20 61 |of input| image a|
|00001080| 6e 64 20 6d 65 63 68 61 | 6e 69 73 6d 20 75 73 65 |nd mecha|nism use|
|00001090| 64 20 74 6f 20 72 65 61 | 64 20 69 74 2e 20 20 54 |d to rea|d it. T|
|000010a0| 68 69 73 20 63 6f 64 65 | 20 69 73 0a 58 20 20 20 |his code| is.X |
|000010b0| 6c 69 6b 65 6c 79 20 74 | 6f 20 76 61 72 79 20 63 |likely t|o vary c|
|000010c0| 6f 6e 73 69 64 65 72 61 | 62 6c 79 20 66 72 6f 6d |onsidera|bly from|
|000010d0| 20 6f 6e 65 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 | one imp|lementat|
|000010e0| 69 6f 6e 20 74 6f 20 61 | 6e 6f 74 68 65 72 2e 20 |ion to a|nother. |
|000010f0| 20 4e 6f 74 65 20 74 68 | 61 74 0a 58 20 20 20 74 | Note th|at.X t|
|00001100| 68 65 20 63 6f 6c 6f 72 | 20 73 70 61 63 65 20 61 |he color| space a|
|00001110| 6e 64 20 6e 75 6d 62 65 | 72 20 6f 66 20 63 6f 6c |nd numbe|r of col|
|00001120| 6f 72 20 63 6f 6d 70 6f | 6e 65 6e 74 73 20 6f 66 |or compo|nents of|
|00001130| 20 74 68 65 20 73 6f 75 | 72 63 65 20 61 72 65 20 | the sou|rce are |
|00001140| 6e 6f 74 20 68 69 64 64 | 65 6e 3b 0a 58 20 20 20 |not hidd|en;.X |
|00001150| 62 75 74 20 74 68 65 79 | 20 61 72 65 20 75 73 65 |but they| are use|
|00001160| 64 20 6f 6e 6c 79 20 62 | 79 20 74 68 65 20 6e 65 |d only b|y the ne|
|00001170| 78 74 20 6f 62 6a 65 63 | 74 2e 29 0a 58 0a 58 32 |xt objec|t.).X.X2|
|00001180| 2e 20 47 61 6d 6d 61 20 | 61 6e 64 20 63 6f 6c 6f |. Gamma |and colo|
|00001190| 72 20 73 70 61 63 65 20 | 63 6f 6e 76 65 72 73 69 |r space |conversi|
|000011a0| 6f 6e 2e 20 20 54 68 69 | 73 20 70 72 6f 76 69 64 |on. Thi|s provid|
|000011b0| 65 73 20 74 68 72 65 65 | 20 6d 65 74 68 6f 64 73 |es three| methods|
|000011c0| 3a 0a 58 09 63 6f 6c 6f | 72 69 6e 5f 69 6e 69 74 |:.X.colo|rin_init|
|000011d0| 3a 20 69 6e 69 74 69 61 | 6c 69 7a 61 74 69 6f 6e |: initia|lization|
|000011e0| 2e 0a 58 09 67 65 74 5f | 73 61 6d 70 6c 65 5f 72 |..X.get_|sample_r|
|000011f0| 6f 77 73 3a 20 72 65 61 | 64 2c 20 63 6f 6e 76 65 |ows: rea|d, conve|
|00001200| 72 74 2c 20 61 6e 64 20 | 72 65 74 75 72 6e 20 61 |rt, and |return a|
|00001210| 20 73 70 65 63 69 66 69 | 65 64 20 6e 75 6d 62 65 | specifi|ed numbe|
|00001220| 72 20 6f 66 20 70 69 78 | 65 6c 0a 58 09 09 09 20 |r of pix|el.X... |
|00001230| 72 6f 77 73 20 28 6e 6f | 74 20 6d 6f 72 65 20 74 |rows (no|t more t|
|00001240| 68 61 6e 20 72 65 6d 61 | 69 6e 20 69 6e 20 74 68 |han rema|in in th|
|00001250| 65 20 70 69 63 74 75 72 | 65 29 2e 0a 58 09 63 6f |e pictur|e)..X.co|
|00001260| 6c 6f 72 69 6e 5f 74 65 | 72 6d 3a 20 66 69 6e 69 |lorin_te|rm: fini|
|00001270| 73 68 20 75 70 20 61 74 | 20 74 68 65 20 65 6e 64 |sh up at| the end|
|00001280| 2e 0a 58 20 20 20 54 68 | 65 20 6d 6f 73 74 20 65 |..X Th|e most e|
|00001290| 66 66 69 63 69 65 6e 74 | 20 61 70 70 72 6f 61 63 |fficient| approac|
|000012a0| 68 20 73 65 65 6d 73 20 | 74 6f 20 62 65 20 66 6f |h seems |to be fo|
|000012b0| 72 20 74 68 69 73 20 6f | 62 6a 65 63 74 20 74 6f |r this o|bject to|
|000012c0| 20 63 61 6c 6c 0a 58 20 | 20 20 67 65 74 5f 69 6e | call.X | get_in|
|000012d0| 70 75 74 5f 72 6f 77 20 | 64 69 72 65 63 74 6c 79 |put_row |directly|
|000012e0| 2c 20 72 61 74 68 65 72 | 20 74 68 61 6e 20 62 65 |, rather| than be|
|000012f0| 69 6e 67 20 70 61 73 73 | 65 64 20 74 68 65 20 69 |ing pass|ed the i|
|00001300| 6e 70 75 74 20 64 61 74 | 61 3b 20 74 68 61 74 20 |nput dat|a; that |
|00001310| 77 61 79 2c 0a 58 20 20 | 20 61 6e 79 20 69 6e 74 |way,.X | any int|
|00001320| 65 72 6d 65 64 69 61 74 | 65 20 73 74 6f 72 61 67 |ermediat|e storag|
|00001330| 65 20 72 65 71 75 69 72 | 65 64 20 63 61 6e 20 62 |e requir|ed can b|
|00001340| 65 20 6c 6f 63 61 6c 20 | 74 6f 20 74 68 69 73 20 |e local |to this |
|00001350| 6f 62 6a 65 63 74 2e 0a | 58 20 20 20 28 67 65 74 |object..|X (get|
|00001360| 5f 73 61 6d 70 6c 65 5f | 72 6f 77 73 20 6d 69 67 |_sample_|rows mig|
|00001370| 68 74 20 74 65 6c 6c 20 | 67 65 74 5f 69 6e 70 75 |ht tell |get_inpu|
|00001380| 74 5f 72 6f 77 20 74 6f | 20 72 65 61 64 20 64 69 |t_row to| read di|
|00001390| 72 65 63 74 6c 79 20 69 | 6e 74 6f 20 69 74 73 20 |rectly i|nto its |
|000013a0| 6f 77 6e 0a 58 20 20 20 | 6f 75 74 70 75 74 20 61 |own.X |output a|
|000013b0| 72 65 61 20 61 6e 64 20 | 74 68 65 6e 20 63 6f 6e |rea and |then con|
|000013c0| 76 65 72 74 20 69 6e 20 | 70 6c 61 63 65 3b 20 6f |vert in |place; o|
|000013d0| 72 20 69 74 20 6d 61 79 | 20 64 6f 20 73 6f 6d 65 |r it may| do some|
|000013e0| 74 68 69 6e 67 20 64 69 | 66 66 65 72 65 6e 74 2e |thing di|fferent.|
|000013f0| 0a 58 20 20 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 |.X For| example|
|00001400| 2c 20 63 6f 6e 76 65 72 | 73 69 6f 6e 20 69 6e 20 |, conver|sion in |
|00001410| 70 6c 61 63 65 20 77 6f | 75 6c 64 6e 27 74 20 77 |place wo|uldn't w|
|00001420| 6f 72 6b 20 69 66 20 69 | 74 20 69 73 20 63 68 61 |ork if i|t is cha|
|00001430| 6e 67 69 6e 67 20 74 68 | 65 20 6e 75 6d 62 65 72 |nging th|e number|
|00001440| 0a 58 20 20 20 6f 66 20 | 63 6f 6c 6f 72 20 63 6f |.X of |color co|
|00001450| 6d 70 6f 6e 65 6e 74 73 | 2e 29 20 20 54 68 65 20 |mponents|.) The |
|00001460| 6f 75 74 70 75 74 20 6f | 66 20 74 68 69 73 20 73 |output o|f this s|
|00001470| 74 65 70 20 69 73 20 69 | 6e 20 74 68 65 20 73 74 |tep is i|n the st|
|00001480| 61 6e 64 61 72 64 69 7a | 65 64 0a 58 20 20 20 73 |andardiz|ed.X s|
|00001490| 61 6d 70 6c 65 20 61 72 | 72 61 79 20 66 6f 72 6d |ample ar|ray form|
|000014a0| 61 74 20 73 68 6f 77 6e | 20 70 72 65 76 69 6f 75 |at shown| previou|
|000014b0| 73 6c 79 2e 0a 58 20 20 | 20 28 48 69 64 65 73 20 |sly..X | (Hides |
|000014c0| 61 6c 6c 20 6b 6e 6f 77 | 6c 65 64 67 65 20 6f 66 |all know|ledge of|
|000014d0| 20 63 6f 6c 6f 72 20 73 | 70 61 63 65 20 73 65 6d | color s|pace sem|
|000014e0| 61 6e 74 69 63 73 20 61 | 6e 64 20 63 6f 6e 76 65 |antics a|nd conve|
|000014f0| 72 73 69 6f 6e 2e 20 20 | 52 65 6d 61 69 6e 69 6e |rsion. |Remainin|
|00001500| 67 0a 58 20 20 20 6d 6f | 64 75 6c 65 73 20 6f 6e |g.X mo|dules on|
|00001510| 6c 79 20 6e 65 65 64 20 | 74 6f 20 6b 6e 6f 77 20 |ly need |to know |
|00001520| 74 68 65 20 6e 75 6d 62 | 65 72 20 6f 66 20 4a 50 |the numb|er of JP|
|00001530| 45 47 20 63 6f 6d 70 6f | 6e 65 6e 74 73 2e 29 0a |EG compo|nents.).|
|00001540| 58 0a 58 33 2e 20 45 64 | 67 65 20 65 78 70 61 6e |X.X3. Ed|ge expan|
|00001550| 73 69 6f 6e 3a 20 6e 65 | 65 64 73 20 6f 6e 6c 79 |sion: ne|eds only|
|00001560| 20 61 20 73 69 6e 67 6c | 65 20 6d 65 74 68 6f 64 | a singl|e method|
|00001570| 2e 0a 58 09 65 64 67 65 | 5f 65 78 70 61 6e 64 3a |..X.edge|_expand:|
|00001580| 20 47 69 76 65 6e 20 61 | 6e 20 4e 78 4d 20 73 61 | Given a|n NxM sa|
|00001590| 6d 70 6c 65 20 61 72 72 | 61 79 2c 20 65 78 70 61 |mple arr|ay, expa|
|000015a0| 6e 64 20 74 6f 20 61 20 | 64 65 73 69 72 65 64 20 |nd to a |desired |
|000015b0| 73 69 7a 65 20 28 61 0a | 58 09 09 20 20 20 20 20 |size (a.|X.. |
|000015c0| 6d 75 6c 74 69 70 6c 65 | 20 6f 66 20 74 68 65 20 |multiple| of the |
|000015d0| 4d 43 55 20 64 69 6d 65 | 6e 73 69 6f 6e 73 29 20 |MCU dime|nsions) |
|000015e0| 62 79 20 64 75 70 6c 69 | 63 61 74 69 6e 67 20 74 |by dupli|cating t|
|000015f0| 68 65 20 6c 61 73 74 0a | 58 09 09 20 20 20 20 20 |he last.|X.. |
|00001600| 72 6f 77 20 6f 72 20 63 | 6f 6c 75 6d 6e 2e 20 20 |row or c|olumn. |
|00001610| 52 65 70 65 61 74 20 66 | 6f 72 20 65 61 63 68 20 |Repeat f|or each |
|00001620| 63 6f 6d 70 6f 6e 65 6e | 74 2e 0a 58 20 20 20 45 |componen|t..X E|
|00001630| 78 70 61 6e 73 69 6f 6e | 20 77 69 6c 6c 20 6f 63 |xpansion| will oc|
|00001640| 63 75 72 20 69 6e 20 70 | 6c 61 63 65 2c 20 73 6f |cur in p|lace, so|
|00001650| 20 74 68 65 20 63 61 6c | 6c 65 72 20 6d 75 73 74 | the cal|ler must|
|00001660| 20 68 61 76 65 20 70 72 | 65 2d 61 6c 6c 6f 63 61 | have pr|e-alloca|
|00001670| 74 65 64 20 65 6e 6f 75 | 67 68 0a 58 20 20 20 73 |ted enou|gh.X s|
|00001680| 74 6f 72 61 67 65 2e 20 | 20 28 49 27 6d 20 61 73 |torage. | (I'm as|
|00001690| 73 75 6d 69 6e 67 20 74 | 68 61 74 20 69 74 20 69 |suming t|hat it i|
|000016a0| 73 20 65 61 73 69 65 72 | 20 61 6e 64 20 66 61 73 |s easier| and fas|
|000016b0| 74 65 72 20 74 6f 20 64 | 6f 20 74 68 69 73 20 65 |ter to d|o this e|
|000016c0| 78 70 61 6e 73 69 6f 6e | 0a 58 20 20 20 74 68 61 |xpansion|.X tha|
|000016d0| 6e 20 69 74 20 69 73 20 | 74 6f 20 77 6f 72 72 79 |n it is |to worry|
|000016e0| 20 61 62 6f 75 74 20 62 | 6f 75 6e 64 61 72 79 20 | about b|oundary |
|000016f0| 63 6f 6e 64 69 74 69 6f | 6e 73 20 69 6e 20 74 68 |conditio|ns in th|
|00001700| 65 20 6e 65 78 74 20 74 | 77 6f 20 73 74 65 70 73 |e next t|wo steps|
|00001710| 2e 0a 58 20 20 20 4e 6f | 74 69 63 65 20 74 68 61 |..X No|tice tha|
|00001720| 74 20 76 65 72 74 69 63 | 61 6c 20 65 78 70 61 6e |t vertic|al expan|
|00001730| 73 69 6f 6e 20 77 69 6c | 6c 20 6f 63 63 75 72 20 |sion wil|l occur |
|00001740| 6f 6e 6c 79 20 6f 6e 63 | 65 2c 20 61 74 20 74 68 |only onc|e, at th|
|00001750| 65 20 62 6f 74 74 6f 6d | 20 6f 66 20 74 68 65 0a |e bottom| of the.|
|00001760| 58 20 20 20 70 69 63 74 | 75 72 65 2c 20 73 6f 20 |X pict|ure, so |
|00001770| 6f 6e 6c 79 20 68 6f 72 | 69 7a 6f 6e 74 61 6c 20 |only hor|izontal |
|00001780| 65 78 70 61 6e 73 69 6f | 6e 20 62 79 20 61 20 66 |expansio|n by a f|
|00001790| 65 77 20 70 69 78 65 6c | 73 20 69 73 20 73 70 65 |ew pixel|s is spe|
|000017a0| 65 64 2d 63 72 69 74 69 | 63 61 6c 2e 29 0a 58 20 |ed-criti|cal.).X |
|000017b0| 20 20 28 54 68 69 73 20 | 64 6f 65 73 6e 27 74 20 | (This |doesn't |
|000017c0| 72 65 61 6c 6c 79 20 68 | 69 64 65 20 61 6e 79 20 |really h|ide any |
|000017d0| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 2c 20 73 6f 20 |informat|ion, so |
|000017e0| 6d 61 79 62 65 20 69 74 | 20 63 6f 75 6c 64 20 62 |maybe it| could b|
|000017f0| 65 20 61 20 73 69 6d 70 | 6c 65 0a 58 20 20 20 73 |e a simp|le.X s|
|00001800| 75 62 72 6f 75 74 69 6e | 65 20 69 6e 73 74 65 61 |ubroutin|e instea|
|00001810| 64 20 6f 66 20 61 20 6d | 65 74 68 6f 64 2e 20 20 |d of a m|ethod. |
|00001820| 44 65 70 65 6e 64 73 20 | 6f 6e 20 77 68 65 74 68 |Depends |on wheth|
|00001830| 65 72 20 77 65 20 77 61 | 6e 74 20 74 6f 20 62 65 |er we wa|nt to be|
|00001840| 20 61 62 6c 65 20 74 6f | 0a 58 20 20 20 75 73 65 | able to|.X use|
|00001850| 20 61 6c 74 65 72 6e 61 | 74 69 76 65 2c 20 6f 70 | alterna|tive, op|
|00001860| 74 69 6d 69 7a 65 64 20 | 6d 65 74 68 6f 64 73 2e |timized |methods.|
|00001870| 29 0a 58 0a 58 34 2e 20 | 44 6f 77 6e 73 61 6d 70 |).X.X4. |Downsamp|
|00001880| 6c 69 6e 67 3a 20 74 68 | 69 73 20 77 69 6c 6c 20 |ling: th|is will |
|00001890| 62 65 20 61 70 70 6c 69 | 65 64 20 74 6f 20 6f 6e |be appli|ed to on|
|000018a0| 65 20 63 6f 6d 70 6f 6e | 65 6e 74 20 61 74 20 61 |e compon|ent at a|
|000018b0| 20 74 69 6d 65 2e 0a 58 | 09 64 6f 77 6e 73 61 6d | time..X|.downsam|
|000018c0| 70 6c 65 5f 69 6e 69 74 | 3a 20 69 6e 69 74 69 61 |ple_init|: initia|
|000018d0| 6c 69 7a 65 20 28 70 72 | 65 63 61 6c 63 75 6c 61 |lize (pr|ecalcula|
|000018e0| 74 65 20 63 6f 6e 76 6f | 6c 75 74 69 6f 6e 20 66 |te convo|lution f|
|000018f0| 61 63 74 6f 72 73 2c 20 | 66 6f 72 0a 58 09 09 09 |actors, |for.X...|
|00001900| 20 65 78 61 6d 70 6c 65 | 29 2e 20 20 54 68 69 73 | example|). This|
|00001910| 20 77 69 6c 6c 20 62 65 | 20 63 61 6c 6c 65 64 20 | will be| called |
|00001920| 6f 6e 63 65 20 70 65 72 | 20 73 63 61 6e 2e 0a 58 |once per| scan..X|
|00001930| 09 64 6f 77 6e 73 61 6d | 70 6c 65 3a 20 47 69 76 |.downsam|ple: Giv|
|00001940| 65 6e 20 61 20 73 61 6d | 70 6c 65 20 61 72 72 61 |en a sam|ple arra|
|00001950| 79 2c 20 72 65 64 75 63 | 65 20 69 74 20 74 6f 20 |y, reduc|e it to |
|00001960| 61 20 73 6d 61 6c 6c 65 | 72 20 6e 75 6d 62 65 72 |a smalle|r number|
|00001970| 20 6f 66 0a 58 09 09 20 | 20 20 20 73 61 6d 70 6c | of.X.. | sampl|
|00001980| 65 73 20 75 73 69 6e 67 | 20 73 70 65 63 69 66 69 |es using| specifi|
|00001990| 65 64 20 73 61 6d 70 6c | 69 6e 67 20 66 61 63 74 |ed sampl|ing fact|
|000019a0| 6f 72 73 2e 0a 58 09 64 | 6f 77 6e 73 61 6d 70 6c |ors..X.d|ownsampl|
|000019b0| 65 5f 74 65 72 6d 3a 20 | 63 6c 65 61 6e 20 75 70 |e_term: |clean up|
|000019c0| 20 61 74 20 74 68 65 20 | 65 6e 64 20 6f 66 20 61 | at the |end of a|
|000019d0| 20 73 63 61 6e 2e 0a 58 | 20 20 20 49 66 20 74 68 | scan..X| If th|
|000019e0| 65 20 63 75 72 72 65 6e | 74 20 63 6f 6d 70 6f 6e |e curren|t compon|
|000019f0| 65 6e 74 20 68 61 73 20 | 76 65 72 74 69 63 61 6c |ent has |vertical|
|00001a00| 20 73 61 6d 70 6c 69 6e | 67 20 66 61 63 74 6f 72 | samplin|g factor|
|00001a10| 20 56 6b 20 61 6e 64 20 | 74 68 65 20 6c 61 72 67 | Vk and |the larg|
|00001a20| 65 73 74 0a 58 20 20 20 | 73 61 6d 70 6c 69 6e 67 |est.X |sampling|
|00001a30| 20 66 61 63 74 6f 72 20 | 69 73 20 56 6d 61 78 2c | factor |is Vmax,|
|00001a40| 20 74 68 65 6e 20 74 68 | 65 20 69 6e 70 75 74 20 | then th|e input |
|00001a50| 69 73 20 61 6c 77 61 79 | 73 20 56 6d 61 78 20 73 |is alway|s Vmax s|
|00001a60| 61 6d 70 6c 65 20 72 6f | 77 73 20 28 77 68 6f 73 |ample ro|ws (whos|
|00001a70| 65 0a 58 20 20 20 77 69 | 64 74 68 20 69 73 20 61 |e.X wi|dth is a|
|00001a80| 20 6d 75 6c 74 69 70 6c | 65 20 6f 66 20 48 6d 61 | multipl|e of Hma|
|00001a90| 78 29 20 61 6e 64 20 74 | 68 65 20 6f 75 74 70 75 |x) and t|he outpu|
|00001aa0| 74 20 69 73 20 61 6c 77 | 61 79 73 20 56 6b 20 73 |t is alw|ays Vk s|
|00001ab0| 61 6d 70 6c 65 20 72 6f | 77 73 2e 0a 58 20 20 20 |ample ro|ws..X |
|00001ac0| 56 6d 61 78 20 61 64 64 | 69 74 69 6f 6e 61 6c 20 |Vmax add|itional |
|00001ad0| 72 6f 77 73 20 61 62 6f | 76 65 20 61 6e 64 20 62 |rows abo|ve and b|
|00001ae0| 65 6c 6f 77 20 74 68 65 | 20 6e 6f 6d 69 6e 61 6c |elow the| nominal|
|00001af0| 20 69 6e 70 75 74 20 72 | 6f 77 73 20 61 72 65 20 | input r|ows are |
|00001b00| 61 6c 73 6f 20 70 61 73 | 73 65 64 0a 58 20 20 20 |also pas|sed.X |
|00001b10| 66 6f 72 20 75 73 65 20 | 62 79 20 70 61 72 74 69 |for use |by parti|
|00001b20| 61 6c 2d 70 69 78 65 6c | 2d 61 76 65 72 61 67 69 |al-pixel|-averagi|
|00001b30| 6e 67 20 73 61 6d 70 6c | 69 6e 67 20 6d 65 74 68 |ng sampl|ing meth|
|00001b40| 6f 64 73 2e 20 20 28 49 | 73 20 74 68 69 73 20 6e |ods. (I|s this n|
|00001b50| 65 63 65 73 73 61 72 79 | 3f 29 0a 58 20 20 20 41 |ecessary|?).X A|
|00001b60| 74 20 74 68 65 20 74 6f | 70 20 61 6e 64 20 62 6f |t the to|p and bo|
|00001b70| 74 74 6f 6d 20 6f 66 20 | 74 68 65 20 69 6d 61 67 |ttom of |the imag|
|00001b80| 65 2c 20 74 68 65 73 65 | 20 65 78 74 72 61 20 72 |e, these| extra r|
|00001b90| 6f 77 73 20 61 72 65 20 | 63 6f 70 69 65 73 20 6f |ows are |copies o|
|00001ba0| 66 20 74 68 65 0a 58 20 | 20 20 66 69 72 73 74 20 |f the.X | first |
|00001bb0| 6f 72 20 6c 61 73 74 20 | 61 63 74 75 61 6c 20 69 |or last |actual i|
|00001bc0| 6e 70 75 74 20 72 6f 77 | 2e 0a 58 20 20 20 28 54 |nput row|..X (T|
|00001bd0| 68 69 73 20 68 69 64 65 | 73 20 77 68 65 74 68 65 |his hide|s whethe|
|00001be0| 72 20 61 6e 64 20 68 6f | 77 20 63 72 6f 73 73 2d |r and ho|w cross-|
|00001bf0| 70 69 78 65 6c 20 61 76 | 65 72 61 67 69 6e 67 20 |pixel av|eraging |
|00001c00| 6f 63 63 75 72 73 2e 29 | 0a 58 0a 58 35 2e 20 4d |occurs.)|.X.X5. M|
|00001c10| 43 55 20 65 78 74 72 61 | 63 74 69 6f 6e 20 28 63 |CU extra|ction (c|
|00001c20| 72 65 61 74 69 6f 6e 20 | 6f 66 20 61 20 73 69 6e |reation |of a sin|
|00001c30| 67 6c 65 20 73 65 71 75 | 65 6e 63 65 20 6f 66 20 |gle sequ|ence of |
|00001c40| 38 78 38 20 73 61 6d 70 | 6c 65 20 62 6c 6f 63 6b |8x8 samp|le block|
|00001c50| 73 29 2e 0a 58 09 65 78 | 74 72 61 63 74 5f 69 6e |s)..X.ex|tract_in|
|00001c60| 69 74 3a 20 69 6e 69 74 | 69 61 6c 69 7a 65 20 61 |it: init|ialize a|
|00001c70| 73 20 6e 65 65 64 65 64 | 2e 20 20 54 68 69 73 20 |s needed|. This |
|00001c80| 77 69 6c 6c 20 62 65 20 | 63 61 6c 6c 65 64 20 6f |will be |called o|
|00001c90| 6e 63 65 20 70 65 72 20 | 73 63 61 6e 2e 0a 58 09 |nce per |scan..X.|
|00001ca0| 65 78 74 72 61 63 74 5f | 4d 43 55 73 3a 20 63 6f |extract_|MCUs: co|
|00001cb0| 6e 76 65 72 74 20 61 20 | 73 61 6d 70 6c 65 20 61 |nvert a |sample a|
|00001cc0| 72 72 61 79 20 74 6f 20 | 61 20 73 65 71 75 65 6e |rray to |a sequen|
|00001cd0| 63 65 20 6f 66 20 4d 43 | 55 73 2e 0a 58 09 65 78 |ce of MC|Us..X.ex|
|00001ce0| 74 72 61 63 74 5f 74 65 | 72 6d 3a 20 63 6c 65 61 |tract_te|rm: clea|
|00001cf0| 6e 20 75 70 20 61 74 20 | 74 68 65 20 65 6e 64 20 |n up at |the end |
|00001d00| 6f 66 20 61 20 73 63 61 | 6e 2e 0a 58 20 20 20 47 |of a sca|n..X G|
|00001d10| 69 76 65 6e 20 6f 6e 65 | 20 6f 72 20 6d 6f 72 65 |iven one| or more|
|00001d20| 20 4d 43 55 20 72 6f 77 | 73 20 77 6f 72 74 68 20 | MCU row|s worth |
|00001d30| 6f 66 20 69 6d 61 67 65 | 20 64 61 74 61 2c 20 65 |of image| data, e|
|00001d40| 78 74 72 61 63 74 20 73 | 61 6d 70 6c 65 20 62 6c |xtract s|ample bl|
|00001d50| 6f 63 6b 73 20 69 6e 20 | 74 68 65 0a 58 20 20 20 |ocks in |the.X |
|00001d60| 61 70 70 72 6f 70 72 69 | 61 74 65 20 6f 72 64 65 |appropri|ate orde|
|00001d70| 72 3b 20 70 61 73 73 20 | 74 68 65 73 65 20 6f 66 |r; pass |these of|
|00001d80| 66 20 74 6f 20 73 75 62 | 73 65 71 75 65 6e 74 20 |f to sub|sequent |
|00001d90| 73 74 65 70 73 20 6f 6e | 65 20 4d 43 55 20 61 74 |steps on|e MCU at|
|00001da0| 20 61 20 74 69 6d 65 2e | 0a 58 20 20 20 54 68 65 | a time.|.X The|
|00001db0| 20 69 6e 70 75 74 20 6d | 75 73 74 20 62 65 20 61 | input m|ust be a|
|00001dc0| 20 6d 75 6c 74 69 70 6c | 65 20 6f 66 20 74 68 65 | multipl|e of the|
|00001dd0| 20 4d 43 55 20 64 69 6d | 65 6e 73 69 6f 6e 73 2e | MCU dim|ensions.|
|00001de0| 20 20 49 74 20 77 69 6c | 6c 20 70 72 6f 62 61 62 | It wil|l probab|
|00001df0| 6c 79 20 62 65 0a 58 20 | 20 20 6d 6f 73 74 20 63 |ly be.X | most c|
|00001e00| 6f 6e 76 65 6e 69 65 6e | 74 20 66 6f 72 20 74 68 |onvenien|t for th|
|00001e10| 65 20 44 43 54 20 74 72 | 61 6e 73 66 6f 72 6d 2c |e DCT tr|ansform,|
|00001e20| 20 66 72 65 71 75 65 6e | 63 79 20 71 75 61 6e 74 | frequen|cy quant|
|00001e30| 69 7a 61 74 69 6f 6e 2c | 20 61 6e 64 20 7a 69 67 |ization,| and zig|
|00001e40| 7a 61 67 0a 58 20 20 20 | 72 65 6f 72 64 65 72 69 |zag.X |reorderi|
|00001e50| 6e 67 20 6f 66 20 65 61 | 63 68 20 62 6c 6f 63 6b |ng of ea|ch block|
|00001e60| 20 74 6f 20 62 65 20 64 | 6f 6e 65 20 61 73 20 73 | to be d|one as s|
|00001e70| 69 6d 70 6c 65 20 73 75 | 62 72 6f 75 74 69 6e 65 |imple su|broutine|
|00001e80| 73 20 6f 66 20 74 68 69 | 73 20 73 74 65 70 2e 0a |s of thi|s step..|
|00001e90| 58 20 20 20 4f 6e 63 65 | 20 61 20 74 72 61 6e 73 |X Once| a trans|
|00001ea0| 66 6f 72 6d 65 64 20 4d | 43 55 20 68 61 73 20 62 |formed M|CU has b|
|00001eb0| 65 65 6e 20 63 6f 6d 70 | 6c 65 74 65 64 2c 20 69 |een comp|leted, i|
|00001ec0| 74 27 6c 6c 20 62 65 20 | 70 61 73 73 65 64 20 6f |t'll be |passed o|
|00001ed0| 66 66 20 74 6f 20 61 0a | 58 20 20 20 6d 65 74 68 |ff to a.|X meth|
|00001ee0| 6f 64 20 63 61 6c 6c 2c | 20 77 68 69 63 68 20 77 |od call,| which w|
|00001ef0| 69 6c 6c 20 62 65 20 70 | 61 73 73 65 64 20 61 73 |ill be p|assed as|
|00001f00| 20 61 20 70 61 72 61 6d | 65 74 65 72 20 74 6f 20 | a param|eter to |
|00001f10| 65 78 74 72 61 63 74 5f | 4d 43 55 73 2e 0a 58 20 |extract_|MCUs..X |
|00001f20| 20 20 54 68 61 74 20 72 | 6f 75 74 69 6e 65 20 6d | That r|outine m|
|00001f30| 69 67 68 74 20 65 69 74 | 68 65 72 20 65 6e 63 6f |ight eit|her enco|
|00001f40| 64 65 20 61 6e 64 20 6f | 75 74 70 75 74 20 74 68 |de and o|utput th|
|00001f50| 65 20 4d 43 55 20 69 6d | 6d 65 64 69 61 74 65 6c |e MCU im|mediatel|
|00001f60| 79 2c 20 6f 72 20 62 75 | 66 66 65 72 0a 58 20 20 |y, or bu|ffer.X |
|00001f70| 20 69 74 20 75 70 20 66 | 6f 72 20 6c 61 74 65 72 | it up f|or later|
|00001f80| 20 6f 75 74 70 75 74 20 | 69 66 20 77 65 20 77 61 | output |if we wa|
|00001f90| 6e 74 20 74 6f 20 64 6f | 20 67 6c 6f 62 61 6c 20 |nt to do| global |
|00001fa0| 6f 70 74 69 6d 69 7a 61 | 74 69 6f 6e 20 6f 66 20 |optimiza|tion of |
|00001fb0| 74 68 65 20 65 6e 74 72 | 6f 70 79 0a 58 20 20 20 |the entr|opy.X |
|00001fc0| 65 6e 63 6f 64 69 6e 67 | 20 63 6f 65 66 66 69 63 |encoding| coeffic|
|00001fd0| 69 65 6e 74 73 2e 20 20 | 4e 6f 74 65 3a 20 77 68 |ients. |Note: wh|
|00001fe0| 65 6e 20 6f 75 74 70 75 | 74 74 69 6e 67 20 61 20 |en outpu|tting a |
|00001ff0| 6e 6f 6e 69 6e 74 65 72 | 6c 65 61 76 65 64 20 66 |noninter|leaved f|
|00002000| 69 6c 65 20 74 68 69 73 | 0a 58 20 20 20 6f 62 6a |ile this|.X obj|
|00002010| 65 63 74 20 77 69 6c 6c | 20 62 65 20 63 61 6c 6c |ect will| be call|
|00002020| 65 64 20 73 65 70 61 72 | 61 74 65 6c 79 20 66 6f |ed separ|ately fo|
|00002030| 72 20 65 61 63 68 20 63 | 6f 6d 70 6f 6e 65 6e 74 |r each c|omponent|
|00002040| 2e 20 20 44 69 72 65 63 | 74 20 6f 75 74 70 75 74 |. Direc|t output|
|00002050| 20 63 6f 75 6c 64 0a 58 | 20 20 20 62 65 20 64 6f | could.X| be do|
|00002060| 6e 65 20 66 6f 72 20 74 | 68 65 20 66 69 72 73 74 |ne for t|he first|
|00002070| 20 63 6f 6d 70 6f 6e 65 | 6e 74 2c 20 62 75 74 20 | compone|nt, but |
|00002080| 74 68 65 20 6f 74 68 65 | 72 73 20 77 6f 75 6c 64 |the othe|rs would|
|00002090| 20 68 61 76 65 20 74 6f | 20 62 65 20 62 75 66 66 | have to| be buff|
|000020a0| 65 72 65 64 2e 0a 58 20 | 20 20 28 41 67 61 69 6e |ered..X | (Again|
|000020b0| 2c 20 61 6e 20 6f 62 6a | 65 63 74 20 6d 61 69 6e |, an obj|ect main|
|000020c0| 6c 79 20 6f 6e 20 74 68 | 65 20 67 72 6f 75 6e 64 |ly on th|e ground|
|000020d0| 73 20 74 68 61 74 20 6d | 75 6c 74 69 70 6c 65 20 |s that m|ultiple |
|000020e0| 69 6e 73 74 61 6e 74 69 | 61 74 69 6f 6e 73 20 6d |instanti|ations m|
|000020f0| 69 67 68 74 0a 58 20 20 | 20 62 65 20 75 73 65 66 |ight.X | be usef|
|00002100| 75 6c 2e 29 0a 58 0a 58 | 36 2e 20 44 43 54 20 74 |ul.).X.X|6. DCT t|
|00002110| 72 61 6e 73 66 6f 72 6d | 61 74 69 6f 6e 20 6f 66 |ransform|ation of|
|00002120| 20 65 61 63 68 20 38 78 | 38 20 62 6c 6f 63 6b 2e | each 8x|8 block.|
|00002130| 20 20 54 68 69 73 20 70 | 72 6f 62 61 62 6c 79 20 | This p|robably |
|00002140| 64 6f 65 73 6e 27 74 20 | 68 61 76 65 20 74 6f 20 |doesn't |have to |
|00002150| 62 65 20 61 0a 58 20 20 | 20 66 75 6c 6c 2d 66 6c |be a.X | full-fl|
|00002160| 65 64 67 65 64 20 6d 65 | 74 68 6f 64 2c 20 62 75 |edged me|thod, bu|
|00002170| 74 20 6a 75 73 74 20 61 | 20 70 6c 61 69 6e 20 73 |t just a| plain s|
|00002180| 75 62 72 6f 75 74 69 6e | 65 20 74 68 61 74 20 77 |ubroutin|e that w|
|00002190| 69 6c 6c 20 62 65 20 63 | 61 6c 6c 65 64 20 62 79 |ill be c|alled by|
|000021a0| 20 4d 43 55 0a 58 20 20 | 20 65 78 74 72 61 63 74 | MCU.X | extract|
|000021b0| 69 6f 6e 2e 20 20 4f 6e | 65 20 38 78 38 20 62 6c |ion. On|e 8x8 bl|
|000021c0| 6f 63 6b 20 77 69 6c 6c | 20 62 65 20 70 72 6f 63 |ock will| be proc|
|000021d0| 65 73 73 65 64 20 70 65 | 72 20 63 61 6c 6c 2e 0a |essed pe|r call..|
|000021e0| 58 0a 58 37 2e 20 51 75 | 61 6e 74 69 7a 61 74 69 |X.X7. Qu|antizati|
|000021f0| 6f 6e 20 73 63 61 6c 69 | 6e 67 20 61 6e 64 20 7a |on scali|ng and z|
|00002200| 69 67 7a 61 67 20 72 65 | 6f 72 64 65 72 69 6e 67 |igzag re|ordering|
|00002210| 20 6f 66 20 74 68 65 20 | 65 6c 65 6d 65 6e 74 73 | of the |elements|
|00002220| 20 69 6e 20 65 61 63 68 | 20 38 78 38 0a 58 20 20 | in each| 8x8.X |
|00002230| 20 62 6c 6f 63 6b 2e 20 | 20 28 54 68 69 73 20 63 | block. | (This c|
|00002240| 61 6e 20 70 72 6f 62 61 | 62 6c 79 20 62 65 20 61 |an proba|bly be a|
|00002250| 20 70 6c 61 69 6e 20 73 | 75 62 72 6f 75 74 69 6e | plain s|ubroutin|
|00002260| 65 20 63 61 6c 6c 65 64 | 20 6f 6e 63 65 20 70 65 |e called| once pe|
|00002270| 72 20 62 6c 6f 63 6b 20 | 62 79 0a 58 20 20 20 4d |r block |by.X M|
|00002280| 43 55 20 65 78 74 72 61 | 63 74 69 6f 6e 3b 20 68 |CU extra|ction; h|
|00002290| 61 72 64 20 74 6f 20 73 | 65 65 20 61 20 6e 65 65 |ard to s|ee a nee|
|000022a0| 64 20 66 6f 72 20 6d 75 | 6c 74 69 70 6c 65 20 69 |d for mu|ltiple i|
|000022b0| 6e 73 74 61 6e 74 69 61 | 74 69 6f 6e 73 20 68 65 |nstantia|tions he|
|000022c0| 72 65 2e 29 0a 58 0a 58 | 38 2e 20 45 6e 74 72 6f |re.).X.X|8. Entro|
|000022d0| 70 79 20 65 6e 63 6f 64 | 69 6e 67 20 28 48 75 66 |py encod|ing (Huf|
|000022e0| 66 6d 61 6e 20 6f 72 20 | 61 72 69 74 68 6d 65 74 |fman or |arithmet|
|000022f0| 69 63 29 2e 0a 58 09 65 | 6e 74 72 6f 70 79 5f 65 |ic)..X.e|ntropy_e|
|00002300| 6e 63 6f 64 65 5f 69 6e | 69 74 3a 20 70 72 65 70 |ncode_in|it: prep|
|00002310| 61 72 65 20 66 6f 72 20 | 6f 6e 65 20 73 63 61 6e |are for |one scan|
|00002320| 2e 0a 58 09 65 6e 74 72 | 6f 70 79 5f 65 6e 63 6f |..X.entr|opy_enco|
|00002330| 64 65 3a 20 61 63 63 65 | 70 74 73 20 61 6e 20 4d |de: acce|pts an M|
|00002340| 43 55 27 73 20 77 6f 72 | 74 68 20 6f 66 20 71 75 |CU's wor|th of qu|
|00002350| 61 6e 74 69 7a 65 64 20 | 63 6f 65 66 66 69 63 69 |antized |coeffici|
|00002360| 65 6e 74 73 2c 0a 58 09 | 09 09 65 6e 63 6f 64 65 |ents,.X.|..encode|
|00002370| 73 20 61 6e 64 20 6f 75 | 74 70 75 74 73 20 74 68 |s and ou|tputs th|
|00002380| 65 6d 2e 0a 58 09 65 6e | 74 72 6f 70 79 5f 65 6e |em..X.en|tropy_en|
|00002390| 63 6f 64 65 5f 74 65 72 | 6d 3a 20 66 69 6e 69 73 |code_ter|m: finis|
|000023a0| 68 20 75 70 20 61 74 20 | 65 6e 64 20 6f 66 20 61 |h up at |end of a|
|000023b0| 20 73 63 61 6e 20 28 64 | 75 6d 70 20 61 6e 79 20 | scan (d|ump any |
|000023c0| 62 75 66 66 65 72 65 64 | 0a 58 09 09 09 20 20 20 |buffered|.X... |
|000023d0| 20 20 62 79 74 65 73 2c | 20 66 6f 72 20 65 78 61 | bytes,| for exa|
|000023e0| 6d 70 6c 65 29 2e 0a 58 | 20 20 20 54 68 65 20 64 |mple)..X| The d|
|000023f0| 61 74 61 20 6f 75 74 70 | 75 74 20 62 79 20 74 68 |ata outp|ut by th|
|00002400| 69 73 20 6d 6f 64 75 6c | 65 20 77 69 6c 6c 20 62 |is modul|e will b|
|00002410| 65 20 73 65 6e 74 20 74 | 6f 20 74 68 65 20 65 6e |e sent t|o the en|
|00002420| 74 72 6f 70 79 5f 6f 75 | 74 70 75 74 20 6d 65 74 |tropy_ou|tput met|
|00002430| 68 6f 64 0a 58 20 20 20 | 70 72 6f 76 69 64 65 64 |hod.X |provided|
|00002440| 20 62 79 20 74 68 65 20 | 70 69 70 65 6c 69 6e 65 | by the |pipeline|
|00002450| 20 63 6f 6e 74 72 6f 6c | 6c 65 72 2e 20 20 28 49 | control|ler. (I|
|00002460| 74 20 77 69 6c 6c 20 70 | 72 6f 62 61 62 6c 79 20 |t will p|robably |
|00002470| 62 65 20 77 6f 72 74 68 | 20 75 73 69 6e 67 0a 58 |be worth| using.X|
|00002480| 20 20 20 62 75 66 66 65 | 72 69 6e 67 20 74 6f 20 | buffe|ring to |
|00002490| 70 61 73 73 20 6d 75 6c | 74 69 70 6c 65 20 62 79 |pass mul|tiple by|
|000024a0| 74 65 73 20 70 65 72 20 | 63 61 6c 6c 20 6f 66 20 |tes per |call of |
|000024b0| 74 68 65 20 6f 75 74 70 | 75 74 20 6d 65 74 68 6f |the outp|ut metho|
|000024c0| 64 2e 29 20 20 54 68 65 | 0a 58 20 20 20 6f 75 74 |d.) The|.X out|
|000024d0| 70 75 74 20 6d 65 74 68 | 6f 64 20 63 6f 75 6c 64 |put meth|od could|
|000024e0| 20 62 65 20 6a 75 73 74 | 20 77 72 69 74 65 5f 6a | be just| write_j|
|000024f0| 70 65 67 5f 64 61 74 61 | 2c 20 62 75 74 20 6d 69 |peg_data|, but mi|
|00002500| 67 68 74 20 61 6c 73 6f | 20 62 65 20 61 20 64 75 |ght also| be a du|
|00002510| 6d 6d 79 0a 58 20 20 20 | 72 6f 75 74 69 6e 65 20 |mmy.X |routine |
|00002520| 74 68 61 74 20 63 6f 75 | 6e 74 73 20 6f 75 74 70 |that cou|nts outp|
|00002530| 75 74 20 62 79 74 65 73 | 20 28 66 6f 72 20 75 73 |ut bytes| (for us|
|00002540| 65 20 64 75 72 69 6e 67 | 20 63 75 74 2d 61 6e 64 |e during| cut-and|
|00002550| 2d 74 72 79 20 63 6f 65 | 66 66 69 63 69 65 6e 74 |-try coe|fficient|
|00002560| 0a 58 20 20 20 6f 70 74 | 69 6d 69 7a 61 74 69 6f |.X opt|imizatio|
|00002570| 6e 29 2e 0a 58 20 20 20 | 28 54 68 69 73 20 68 69 |n)..X |(This hi|
|00002580| 64 65 73 20 77 68 69 63 | 68 20 65 6e 74 72 6f 70 |des whic|h entrop|
|00002590| 79 20 65 6e 63 6f 64 69 | 6e 67 20 6d 65 74 68 6f |y encodi|ng metho|
|000025a0| 64 20 69 73 20 69 6e 20 | 75 73 65 2e 29 0a 58 0a |d is in |use.).X.|
|000025b0| 58 39 2e 20 4a 50 45 47 | 20 66 69 6c 65 20 68 65 |X9. JPEG| file he|
|000025c0| 61 64 65 72 20 63 6f 6e | 73 74 72 75 63 74 69 6f |ader con|structio|
|000025d0| 6e 2e 20 20 54 68 69 73 | 20 77 69 6c 6c 20 70 72 |n. This| will pr|
|000025e0| 6f 76 69 64 65 20 74 68 | 65 73 65 20 6d 65 74 68 |ovide th|ese meth|
|000025f0| 6f 64 73 3a 0a 58 09 77 | 72 69 74 65 5f 66 69 6c |ods:.X.w|rite_fil|
|00002600| 65 5f 68 65 61 64 65 72 | 3a 20 6f 75 74 70 75 74 |e_header|: output|
|00002610| 20 74 68 65 20 69 6e 69 | 74 69 61 6c 20 68 65 61 | the ini|tial hea|
|00002620| 64 65 72 2e 0a 58 09 77 | 72 69 74 65 5f 73 63 61 |der..X.w|rite_sca|
|00002630| 6e 5f 68 65 61 64 65 72 | 3a 20 6f 75 74 70 75 74 |n_header|: output|
|00002640| 20 73 63 61 6e 20 68 65 | 61 64 65 72 20 28 63 61 | scan he|ader (ca|
|00002650| 6c 6c 65 64 20 6f 6e 63 | 65 20 70 65 72 20 63 6f |lled onc|e per co|
|00002660| 6d 70 6f 6e 65 6e 74 0a | 58 09 09 09 20 20 20 69 |mponent.|X... i|
|00002670| 66 20 6e 6f 6e 69 6e 74 | 65 72 6c 65 61 76 65 64 |f nonint|erleaved|
|00002680| 20 6d 6f 64 65 29 2e 0a | 58 09 77 72 69 74 65 5f | mode)..|X.write_|
|00002690| 6a 70 65 67 5f 64 61 74 | 61 3a 20 74 68 65 20 61 |jpeg_dat|a: the a|
|000026a0| 63 74 75 61 6c 20 64 61 | 74 61 20 6f 75 74 70 75 |ctual da|ta outpu|
|000026b0| 74 20 6d 65 74 68 6f 64 | 20 66 6f 72 20 74 68 65 |t method| for the|
|000026c0| 20 70 72 65 63 65 64 69 | 6e 67 20 73 74 65 70 2e | precedi|ng step.|
|000026d0| 0a 58 09 77 72 69 74 65 | 5f 73 63 61 6e 5f 74 72 |.X.write|_scan_tr|
|000026e0| 61 69 6c 65 72 3a 20 66 | 69 6e 69 73 68 20 75 70 |ailer: f|inish up|
|000026f0| 20 61 66 74 65 72 20 6f | 6e 65 20 73 63 61 6e 2e | after o|ne scan.|
|00002700| 0a 58 09 77 72 69 74 65 | 5f 66 69 6c 65 5f 74 72 |.X.write|_file_tr|
|00002710| 61 69 6c 65 72 3a 20 66 | 69 6e 69 73 68 20 75 70 |ailer: f|inish up|
|00002720| 20 61 74 20 65 6e 64 20 | 6f 66 20 66 69 6c 65 2e | at end |of file.|
|00002730| 0a 58 20 20 20 4e 6f 74 | 65 20 74 68 61 74 20 63 |.X Not|e that c|
|00002740| 6f 6d 70 72 65 73 73 65 | 64 20 64 61 74 61 20 69 |ompresse|d data i|
|00002750| 73 20 70 61 73 73 65 64 | 20 74 6f 20 74 68 65 20 |s passed| to the |
|00002760| 77 72 69 74 65 5f 6a 70 | 65 67 5f 64 61 74 61 20 |write_jp|eg_data |
|00002770| 6d 65 74 68 6f 64 2c 20 | 69 6e 20 63 61 73 65 0a |method, |in case.|
|00002780| 58 20 20 20 61 20 73 69 | 6d 70 6c 65 20 66 77 72 |X a si|mple fwr|
|00002790| 69 74 65 20 69 73 6e 27 | 74 20 61 70 70 72 6f 70 |ite isn'|t approp|
|000027a0| 72 69 61 74 65 20 66 6f | 72 20 73 6f 6d 65 20 72 |riate fo|r some r|
|000027b0| 65 61 73 6f 6e 2e 0a 58 | 20 20 20 28 54 68 69 73 |eason..X| (This|
|000027c0| 20 68 69 64 65 73 20 77 | 68 69 63 68 20 76 61 72 | hides w|hich var|
|000027d0| 69 61 6e 74 20 4a 50 45 | 47 20 66 69 6c 65 20 66 |iant JPE|G file f|
|000027e0| 6f 72 6d 61 74 20 69 73 | 20 62 65 69 6e 67 20 77 |ormat is| being w|
|000027f0| 72 69 74 74 65 6e 2e 20 | 20 41 6c 73 6f 2c 20 74 |ritten. | Also, t|
|00002800| 68 65 0a 58 20 20 20 61 | 63 74 75 61 6c 20 6d 65 |he.X a|ctual me|
|00002810| 63 68 61 6e 69 73 6d 20 | 66 6f 72 20 77 72 69 74 |chanism |for writ|
|00002820| 69 6e 67 20 74 68 65 20 | 66 69 6c 65 20 69 73 20 |ing the |file is |
|00002830| 70 72 69 76 61 74 65 20 | 74 6f 20 74 68 69 73 20 |private |to this |
|00002840| 6f 62 6a 65 63 74 20 61 | 6e 64 20 74 68 65 0a 58 |object a|nd the.X|
|00002850| 20 20 20 75 73 65 72 20 | 69 6e 74 65 72 66 61 63 | user |interfac|
|00002860| 65 2e 29 0a 58 0a 58 31 | 30 2e 20 50 69 70 65 6c |e.).X.X1|0. Pipel|
|00002870| 69 6e 65 20 63 6f 6e 74 | 72 6f 6c 2e 20 20 54 68 |ine cont|rol. Th|
|00002880| 69 73 20 6f 62 6a 65 63 | 74 20 77 69 6c 6c 20 70 |is objec|t will p|
|00002890| 72 6f 76 69 64 65 20 74 | 68 65 20 22 6d 61 69 6e |rovide t|he "main|
|000028a0| 20 6c 6f 6f 70 22 20 74 | 68 61 74 20 69 6e 76 6f | loop" t|hat invo|
|000028b0| 6b 65 73 0a 58 20 20 20 | 20 61 6c 6c 20 74 68 65 |kes.X | all the|
|000028c0| 20 70 69 70 65 6c 69 6e | 65 20 6f 62 6a 65 63 74 | pipelin|e object|
|000028d0| 73 2e 20 20 4e 6f 74 65 | 20 74 68 61 74 20 77 65 |s. Note| that we|
|000028e0| 20 77 69 6c 6c 20 6e 65 | 65 64 20 73 65 76 65 72 | will ne|ed sever|
|000028f0| 61 6c 20 64 69 66 66 65 | 72 65 6e 74 20 6d 61 69 |al diffe|rent mai|
|00002900| 6e 0a 58 20 20 20 20 6c | 6f 6f 70 73 20 64 65 70 |n.X l|oops dep|
|00002910| 65 6e 64 69 6e 67 20 6f | 6e 20 74 68 65 20 73 69 |ending o|n the si|
|00002920| 74 75 61 74 69 6f 6e 20 | 28 69 6e 74 65 72 6c 65 |tuation |(interle|
|00002930| 61 76 65 64 20 6f 75 74 | 70 75 74 20 6f 72 20 6e |aved out|put or n|
|00002940| 6f 74 2c 20 67 6c 6f 62 | 61 6c 0a 58 20 20 20 20 |ot, glob|al.X |
|00002950| 6f 70 74 69 6d 69 7a 61 | 74 69 6f 6e 20 6f 66 20 |optimiza|tion of |
|00002960| 65 6e 63 6f 64 69 6e 67 | 20 70 61 72 61 6d 65 74 |encoding| paramet|
|00002970| 65 72 73 20 6f 72 20 6e | 6f 74 2c 20 65 74 63 29 |ers or n|ot, etc)|
|00002980| 2e 20 20 54 68 69 73 20 | 6f 62 6a 65 63 74 20 77 |. This |object w|
|00002990| 69 6c 6c 20 64 6f 0a 58 | 20 20 20 20 6d 6f 73 74 |ill do.X| most|
|000029a0| 20 6f 66 20 74 68 65 20 | 6d 65 6d 6f 72 79 20 61 | of the |memory a|
|000029b0| 6c 6c 6f 63 61 74 69 6f | 6e 2c 20 73 69 6e 63 65 |llocatio|n, since|
|000029c0| 20 69 74 20 77 69 6c 6c | 20 70 72 6f 76 69 64 65 | it will| provide|
|000029d0| 20 74 68 65 20 77 6f 72 | 6b 69 6e 67 20 62 75 66 | the wor|king buf|
|000029e0| 66 65 72 73 0a 58 20 20 | 20 20 74 68 61 74 20 61 |fers.X | that a|
|000029f0| 72 65 20 74 68 65 20 69 | 6e 70 75 74 73 20 61 6e |re the i|nputs an|
|00002a00| 64 20 6f 75 74 70 75 74 | 73 20 6f 66 20 74 68 65 |d output|s of the|
|00002a10| 20 70 69 70 65 6c 69 6e | 65 20 73 74 65 70 73 2e | pipelin|e steps.|
|00002a20| 0a 58 20 20 20 20 28 41 | 6e 20 6f 62 6a 65 63 74 |.X (A|n object|
|00002a30| 20 6d 6f 73 74 6c 79 20 | 74 6f 20 73 75 70 70 6f | mostly |to suppo|
|00002a40| 72 74 20 6d 75 6c 74 69 | 70 6c 65 20 69 6e 73 74 |rt multi|ple inst|
|00002a50| 61 6e 74 69 61 74 69 6f | 6e 73 3b 20 68 6f 77 65 |antiatio|ns; howe|
|00002a60| 76 65 72 2c 20 6f 76 65 | 72 61 6c 6c 0a 58 20 20 |ver, ove|rall.X |
|00002a70| 20 20 6d 65 6d 6f 72 79 | 20 6d 61 6e 61 67 65 6d | memory| managem|
|00002a80| 65 6e 74 20 61 6e 64 20 | 73 65 71 75 65 6e 63 69 |ent and |sequenci|
|00002a90| 6e 67 20 6f 66 20 6f 70 | 65 72 61 74 69 6f 6e 73 |ng of op|erations|
|00002aa0| 20 61 72 65 20 6b 6e 6f | 77 6e 20 6f 6e 6c 79 20 | are kno|wn only |
|00002ab0| 68 65 72 65 2e 29 0a 58 | 0a 58 31 31 2e 20 4f 76 |here.).X|.X11. Ov|
|00002ac0| 65 72 61 6c 6c 20 63 6f | 6e 74 72 6f 6c 2e 20 20 |erall co|ntrol. |
|00002ad0| 54 68 69 73 20 6d 6f 64 | 75 6c 65 20 77 69 6c 6c |This mod|ule will|
|00002ae0| 20 70 72 6f 76 69 64 65 | 20 61 74 20 6c 65 61 73 | provide| at leas|
|00002af0| 74 20 74 77 6f 20 72 6f | 75 74 69 6e 65 73 3a 0a |t two ro|utines:.|
|00002b00| 58 09 6a 70 65 67 5f 63 | 6f 6d 70 72 65 73 73 3a |X.jpeg_c|ompress:|
|00002b10| 20 74 68 65 20 6d 61 69 | 6e 20 65 6e 74 72 79 20 | the mai|n entry |
|00002b20| 70 6f 69 6e 74 20 74 6f | 20 74 68 65 20 63 6f 6d |point to| the com|
|00002b30| 70 72 65 73 73 6f 72 2e | 0a 58 09 70 65 72 5f 73 |pressor.|.X.per_s|
|00002b40| 63 61 6e 5f 6d 65 74 68 | 6f 64 5f 73 65 6c 65 63 |can_meth|od_selec|
|00002b50| 74 69 6f 6e 3a 20 63 61 | 6c 6c 65 64 20 62 79 20 |tion: ca|lled by |
|00002b60| 70 69 70 65 6c 69 6e 65 | 20 63 6f 6e 74 72 6f 6c |pipeline| control|
|00002b70| 6c 65 72 73 20 66 6f 72 | 0a 58 09 09 09 09 20 20 |lers for|.X.... |
|00002b80| 20 73 65 63 6f 6e 64 61 | 72 79 20 6d 65 74 68 6f | seconda|ry metho|
|00002b90| 64 20 73 65 6c 65 63 74 | 69 6f 6e 20 70 61 73 73 |d select|ion pass|
|00002ba0| 65 73 2e 0a 58 20 20 20 | 20 6a 70 65 67 5f 63 6f |es..X | jpeg_co|
|00002bb0| 6d 70 72 65 73 73 20 69 | 73 20 69 6e 76 6f 6b 65 |mpress i|s invoke|
|00002bc0| 64 20 66 72 6f 6d 20 74 | 68 65 20 75 73 65 72 20 |d from t|he user |
|00002bd0| 69 6e 74 65 72 66 61 63 | 65 20 61 66 74 65 72 20 |interfac|e after |
|00002be0| 74 68 65 20 55 49 20 68 | 61 73 20 73 65 6c 65 63 |the UI h|as selec|
|00002bf0| 74 65 64 0a 58 20 20 20 | 20 74 68 65 20 69 6e 70 |ted.X | the inp|
|00002c00| 75 74 20 61 6e 64 20 6f | 75 74 70 75 74 20 66 69 |ut and o|utput fi|
|00002c10| 6c 65 73 20 61 6e 64 20 | 6f 62 74 61 69 6e 65 64 |les and |obtained|
|00002c20| 20 76 61 6c 75 65 73 20 | 66 6f 72 20 61 6c 6c 20 | values |for all |
|00002c30| 63 6f 6d 70 72 65 73 73 | 69 6f 6e 0a 58 20 20 20 |compress|ion.X |
|00002c40| 20 70 61 72 61 6d 65 74 | 65 72 73 20 74 68 61 74 | paramet|ers that|
|00002c50| 20 61 72 65 6e 27 74 20 | 64 79 6e 61 6d 69 63 61 | aren't |dynamica|
|00002c60| 6c 6c 79 20 64 65 74 65 | 72 6d 69 6e 65 64 2e 20 |lly dete|rmined. |
|00002c70| 20 6a 70 65 67 5f 63 6f | 6d 70 72 65 73 73 20 70 | jpeg_co|mpress p|
|00002c80| 65 72 66 6f 72 6d 73 0a | 58 20 20 20 20 62 61 73 |erforms.|X bas|
|00002c90| 69 63 20 69 6e 69 74 69 | 61 6c 69 7a 61 74 69 6f |ic initi|alizatio|
|00002ca0| 6e 20 28 65 2e 67 2e 2c | 20 63 61 6c 63 75 6c 61 |n (e.g.,| calcula|
|00002cb0| 74 69 6e 67 20 74 68 65 | 20 73 69 7a 65 20 6f 66 |ting the| size of|
|00002cc0| 20 4d 43 55 73 29 2c 20 | 64 6f 65 73 20 74 68 65 | MCUs), |does the|
|00002cd0| 0a 58 20 20 20 20 22 67 | 6c 6f 62 61 6c 22 20 6d |.X "g|lobal" m|
|00002ce0| 65 74 68 6f 64 20 73 65 | 6c 65 63 74 69 6f 6e 20 |ethod se|lection |
|00002cf0| 70 61 73 73 2c 20 61 6e | 64 20 66 69 6e 61 6c 6c |pass, an|d finall|
|00002d00| 79 20 63 61 6c 6c 73 20 | 74 68 65 20 73 65 6c 65 |y calls |the sele|
|00002d10| 63 74 65 64 20 70 69 70 | 65 6c 69 6e 65 0a 58 20 |cted pip|eline.X |
|00002d20| 20 20 20 63 6f 6e 74 72 | 6f 6c 20 6f 62 6a 65 63 | contr|ol objec|
|00002d30| 74 2e 20 20 28 50 65 72 | 2d 73 63 61 6e 20 6d 65 |t. (Per|-scan me|
|00002d40| 74 68 6f 64 20 73 65 6c | 65 63 74 69 6f 6e 73 20 |thod sel|ections |
|00002d50| 77 69 6c 6c 20 62 65 20 | 69 6e 76 6f 6b 65 64 20 |will be |invoked |
|00002d60| 62 79 20 74 68 65 0a 58 | 20 20 20 20 70 69 70 65 |by the.X| pipe|
|00002d70| 6c 69 6e 65 20 63 6f 6e | 74 72 6f 6c 6c 65 72 2e |line con|troller.|
|00002d80| 29 0a 58 20 20 20 20 4e | 6f 74 65 20 74 68 61 74 |).X N|ote that|
|00002d90| 20 6a 70 65 67 5f 63 6f | 6d 70 72 65 73 73 20 63 | jpeg_co|mpress c|
|00002da0| 61 6e 27 74 20 62 65 20 | 61 20 6d 65 74 68 6f 64 |an't be |a method|
|00002db0| 20 73 69 6e 63 65 20 69 | 74 20 69 73 20 69 6e 76 | since i|t is inv|
|00002dc0| 6f 6b 65 64 20 70 72 69 | 6f 72 20 74 6f 0a 58 20 |oked pri|or to.X |
|00002dd0| 20 20 20 6d 65 74 68 6f | 64 20 73 65 6c 65 63 74 | metho|d select|
|00002de0| 69 6f 6e 2e 0a 58 0a 58 | 31 32 2e 20 55 73 65 72 |ion..X.X|12. User|
|00002df0| 20 69 6e 74 65 72 66 61 | 63 65 3b 20 74 68 69 73 | interfa|ce; this|
|00002e00| 20 69 73 20 74 68 65 20 | 61 72 63 68 69 74 65 63 | is the |architec|
|00002e10| 74 75 72 65 27 73 20 74 | 65 72 6d 20 66 6f 72 20 |ture's t|erm for |
|00002e20| 22 74 68 65 20 72 65 73 | 74 20 6f 66 20 74 68 65 |"the res|t of the|
|00002e30| 0a 58 20 20 20 20 61 70 | 70 6c 69 63 61 74 69 6f |.X ap|plicatio|
|00002e40| 6e 20 70 72 6f 67 72 61 | 6d 22 2c 20 69 2e 65 2e |n progra|m", i.e.|
|00002e50| 2c 20 74 68 61 74 20 77 | 68 69 63 68 20 69 6e 76 |, that w|hich inv|
|00002e60| 6f 6b 65 73 20 74 68 65 | 20 4a 50 45 47 20 63 6f |okes the| JPEG co|
|00002e70| 6d 70 72 65 73 73 6f 72 | 2e 20 20 49 6e 20 61 0a |mpressor|. In a.|
|00002e80| 58 20 20 20 20 73 74 61 | 6e 64 61 6c 6f 6e 65 20 |X sta|ndalone |
|00002e90| 4a 50 45 47 20 63 6f 6d | 70 72 65 73 73 69 6f 6e |JPEG com|pression|
|00002ea0| 20 70 72 6f 67 72 61 6d | 20 74 68 65 20 55 49 20 | program| the UI |
|00002eb0| 6e 65 65 64 20 62 65 20 | 6c 69 74 74 6c 65 20 6d |need be |little m|
|00002ec0| 6f 72 65 20 74 68 61 6e | 20 61 20 43 0a 58 20 20 |ore than| a C.X |
|00002ed0| 20 20 6d 61 69 6e 28 29 | 20 72 6f 75 74 69 6e 65 | main()| routine|
|00002ee0| 20 61 6e 64 20 61 72 67 | 75 6d 65 6e 74 20 70 61 | and arg|ument pa|
|00002ef0| 72 73 69 6e 67 20 63 6f | 64 65 3b 20 62 75 74 20 |rsing co|de; but |
|00002f00| 77 65 20 63 61 6e 20 65 | 78 70 65 63 74 20 74 68 |we can e|xpect th|
|00002f10| 61 74 20 74 68 65 20 4a | 50 45 47 0a 58 20 20 20 |at the J|PEG.X |
|00002f20| 20 63 6f 6d 70 72 65 73 | 73 6f 72 20 6d 61 79 20 | compres|sor may |
|00002f30| 62 65 20 69 6e 63 6f 72 | 70 6f 72 61 74 65 64 20 |be incor|porated |
|00002f40| 69 6e 74 6f 20 63 6f 6d | 70 6c 65 78 20 67 72 61 |into com|plex gra|
|00002f50| 70 68 69 63 73 20 61 70 | 70 6c 69 63 61 74 69 6f |phics ap|plicatio|
|00002f60| 6e 73 2c 20 77 68 65 72 | 65 69 6e 0a 58 20 20 20 |ns, wher|ein.X |
|00002f70| 20 74 68 65 20 55 49 20 | 69 73 20 6d 75 63 68 20 | the UI |is much |
|00002f80| 6d 6f 72 65 20 63 6f 6d | 70 6c 65 78 2e 20 20 4d |more com|plex. M|
|00002f90| 75 63 68 20 6f 66 20 74 | 68 65 20 55 49 20 77 69 |uch of t|he UI wi|
|00002fa0| 6c 6c 20 6e 65 65 64 20 | 74 6f 20 62 65 20 77 72 |ll need |to be wr|
|00002fb0| 69 74 74 65 6e 0a 58 20 | 20 20 20 61 66 72 65 73 |itten.X | afres|
|00002fc0| 68 20 66 6f 72 20 65 61 | 63 68 20 6e 6f 6e 2d 55 |h for ea|ch non-U|
|00002fd0| 6e 69 78 2d 6c 69 6b 65 | 20 70 6c 61 74 66 6f 72 |nix-like| platfor|
|00002fe0| 6d 20 74 68 65 20 63 6f | 6d 70 72 65 73 73 6f 72 |m the co|mpressor|
|00002ff0| 20 69 73 20 70 6f 72 74 | 65 64 20 74 6f 2e 0a 58 | is port|ed to..X|
|00003000| 20 20 20 20 54 68 65 20 | 55 49 20 69 73 20 65 78 | The |UI is ex|
|00003010| 70 65 63 74 65 64 20 74 | 6f 20 73 75 70 70 6c 79 |pected t|o supply|
|00003020| 20 69 6e 70 75 74 20 61 | 6e 64 20 6f 75 74 70 75 | input a|nd outpu|
|00003030| 74 20 66 69 6c 65 73 20 | 61 6e 64 20 76 61 6c 75 |t files |and valu|
|00003040| 65 73 20 66 6f 72 20 61 | 6c 6c 0a 58 20 20 20 20 |es for a|ll.X |
|00003050| 6e 6f 6e 2d 61 75 74 6f | 6d 61 74 69 63 61 6c 6c |non-auto|maticall|
|00003060| 79 2d 63 68 6f 73 65 6e | 20 63 6f 6d 70 72 65 73 |y-chosen| compres|
|00003070| 73 69 6f 6e 20 70 61 72 | 61 6d 65 74 65 72 73 2e |sion par|ameters.|
|00003080| 20 20 28 48 65 6e 63 65 | 20 64 65 66 61 75 6c 74 | (Hence| default|
|00003090| 73 20 61 72 65 0a 58 20 | 20 20 20 64 65 74 65 72 |s are.X | deter|
|000030a0| 6d 69 6e 65 64 20 62 79 | 20 74 68 65 20 55 49 3b |mined by| the UI;|
|000030b0| 20 77 65 20 73 68 6f 75 | 6c 64 20 70 72 6f 76 69 | we shou|ld provi|
|000030c0| 64 65 20 68 65 6c 70 66 | 75 6c 20 72 6f 75 74 69 |de helpf|ul routi|
|000030d0| 6e 65 73 20 74 6f 20 66 | 69 6c 6c 20 69 6e 0a 58 |nes to f|ill in.X|
|000030e0| 20 20 20 20 74 68 65 20 | 72 65 63 6f 6d 6d 65 6e | the |recommen|
|000030f0| 64 65 64 20 64 65 66 61 | 75 6c 74 73 2e 29 20 20 |ded defa|ults.) |
|00003100| 54 68 65 20 55 49 20 6d | 75 73 74 20 61 6c 73 6f |The UI m|ust also|
|00003110| 20 73 75 70 70 6c 79 20 | 65 72 72 6f 72 20 68 61 | supply |error ha|
|00003120| 6e 64 6c 69 6e 67 0a 58 | 20 20 20 20 72 6f 75 74 |ndling.X| rout|
|00003130| 69 6e 65 73 20 61 6e 64 | 20 73 6f 6d 65 20 6d 65 |ines and| some me|
|00003140| 63 68 61 6e 69 73 6d 20 | 66 6f 72 20 74 72 61 63 |chanism |for trac|
|00003150| 65 20 6d 65 73 73 61 67 | 65 73 2e 0a 58 20 20 20 |e messag|es..X |
|00003160| 20 28 54 68 69 73 20 6d | 6f 64 75 6c 65 20 68 69 | (This m|odule hi|
|00003170| 64 65 73 20 74 68 65 20 | 75 73 65 72 20 69 6e 74 |des the |user int|
|00003180| 65 72 66 61 63 65 20 70 | 72 6f 76 69 64 65 64 20 |erface p|rovided |
|00003190| 2d 2d 2d 20 63 6f 6d 6d | 61 6e 64 20 6c 69 6e 65 |--- comm|and line|
|000031a0| 2c 0a 58 20 20 20 20 69 | 6e 74 65 72 61 63 74 69 |,.X i|nteracti|
|000031b0| 76 65 2c 20 65 74 63 2e | 20 20 45 78 63 65 70 74 |ve, etc.| Except|
|000031c0| 20 66 6f 72 20 65 72 72 | 6f 72 2f 6d 65 73 73 61 | for err|or/messa|
|000031d0| 67 65 20 68 61 6e 64 6c | 69 6e 67 2c 20 74 68 65 |ge handl|ing, the|
|000031e0| 20 55 49 20 63 61 6c 6c | 73 20 74 68 65 0a 58 20 | UI call|s the.X |
|000031f0| 20 20 20 70 6f 72 74 61 | 62 6c 65 20 4a 50 45 47 | porta|ble JPEG|
|00003200| 20 63 6f 64 65 2c 20 6e | 6f 74 20 74 68 65 20 6f | code, n|ot the o|
|00003210| 74 68 65 72 20 77 61 79 | 20 61 72 6f 75 6e 64 2e |ther way| around.|
|00003220| 29 0a 58 0a 58 31 33 2e | 20 28 4f 70 74 69 6f 6e |).X.X13.| (Option|
|00003230| 61 6c 29 20 43 6f 6d 70 | 72 65 73 73 69 6f 6e 20 |al) Comp|ression |
|00003240| 70 61 72 61 6d 65 74 65 | 72 20 73 65 6c 65 63 74 |paramete|r select|
|00003250| 69 6f 6e 20 63 6f 6e 74 | 72 6f 6c 2e 0a 58 09 65 |ion cont|rol..X.e|
|00003260| 6e 74 72 6f 70 79 5f 6f | 70 74 69 6d 69 7a 65 3a |ntropy_o|ptimize:|
|00003270| 20 67 69 76 65 6e 20 61 | 6e 20 61 72 72 61 79 20 | given a|n array |
|00003280| 6f 66 20 4d 43 55 73 20 | 72 65 61 64 79 20 74 6f |of MCUs |ready to|
|00003290| 20 62 65 20 66 65 64 20 | 74 6f 20 65 6e 74 72 6f | be fed |to entro|
|000032a0| 70 79 0a 58 09 09 09 20 | 20 65 6e 63 6f 64 69 6e |py.X... | encodin|
|000032b0| 67 2c 20 66 69 6e 64 20 | 6f 70 74 69 6d 61 6c 20 |g, find |optimal |
|000032c0| 65 6e 63 6f 64 69 6e 67 | 20 70 61 72 61 6d 65 74 |encoding| paramet|
|000032d0| 65 72 73 2e 0a 58 20 20 | 20 20 54 68 65 20 61 63 |ers..X | The ac|
|000032e0| 74 75 61 6c 20 6f 70 74 | 69 6d 69 7a 61 74 69 6f |tual opt|imizatio|
|000032f0| 6e 20 61 6c 67 6f 72 69 | 74 68 6d 20 6f 75 67 68 |n algori|thm ough|
|00003300| 74 20 74 6f 20 62 65 20 | 73 65 70 61 72 61 74 65 |t to be |separate|
|00003310| 64 20 6f 75 74 20 61 73 | 20 61 6e 20 6f 62 6a 65 |d out as| an obje|
|00003320| 63 74 2c 0a 58 20 20 20 | 20 65 76 65 6e 20 74 68 |ct,.X | even th|
|00003330| 6f 75 67 68 20 61 20 73 | 70 65 63 69 61 6c 20 70 |ough a s|pecial p|
|00003340| 69 70 65 6c 69 6e 65 20 | 63 6f 6e 74 72 6f 6c 20 |ipeline |control |
|00003350| 6d 65 74 68 6f 64 20 77 | 69 6c 6c 20 62 65 20 6e |method w|ill be n|
|00003360| 65 65 64 65 64 2e 20 20 | 28 54 68 65 0a 58 20 20 |eeded. |(The.X |
|00003370| 20 20 70 69 70 65 6c 69 | 6e 65 20 63 6f 6e 74 72 | pipeli|ne contr|
|00003380| 6f 6c 6c 65 72 20 6f 6e | 6c 79 20 68 61 73 20 74 |oller on|ly has t|
|00003390| 6f 20 75 6e 64 65 72 73 | 74 61 6e 64 20 74 68 61 |o unders|tand tha|
|000033a0| 74 20 74 68 65 20 6f 75 | 74 70 75 74 20 6f 66 20 |t the ou|tput of |
|000033b0| 65 78 74 72 61 63 74 5f | 4d 43 55 73 0a 58 20 20 |extract_|MCUs.X |
|000033c0| 20 20 6d 75 73 74 20 62 | 65 20 62 75 69 6c 74 20 | must b|e built |
|000033d0| 75 70 20 61 73 20 61 20 | 76 69 72 74 75 61 6c 20 |up as a |virtual |
|000033e0| 61 72 72 61 79 20 72 61 | 74 68 65 72 20 74 68 61 |array ra|ther tha|
|000033f0| 6e 20 66 65 64 20 64 69 | 72 65 63 74 6c 79 20 74 |n fed di|rectly t|
|00003400| 6f 20 65 6e 74 72 6f 70 | 79 0a 58 20 20 20 20 65 |o entrop|y.X e|
|00003410| 6e 63 6f 64 69 6e 67 20 | 61 6e 64 20 6f 75 74 70 |ncoding |and outp|
|00003420| 75 74 2e 20 20 54 68 69 | 73 20 70 69 70 65 6c 69 |ut. Thi|s pipeli|
|00003430| 6e 65 20 62 65 68 61 76 | 69 6f 72 20 6d 61 79 20 |ne behav|ior may |
|00003440| 61 6c 73 6f 20 62 65 20 | 75 73 65 66 75 6c 20 66 |also be |useful f|
|00003450| 6f 72 20 66 75 74 75 72 | 65 0a 58 20 20 20 20 69 |or futur|e.X i|
|00003460| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 20 6f 66 |mplement|ation of|
|00003470| 20 68 69 65 72 61 72 63 | 68 69 63 61 6c 20 6d 6f | hierarc|hical mo|
|00003480| 64 65 73 2c 20 65 74 63 | 2e 29 0a 58 20 20 20 20 |des, etc|.).X |
|00003490| 54 6f 20 6d 69 6e 69 6d | 69 7a 65 20 74 68 65 20 |To minim|ize the |
|000034a0| 61 6d 6f 75 6e 74 20 6f | 66 20 63 6f 6e 74 72 6f |amount o|f contro|
|000034b0| 6c 20 6c 6f 67 69 63 20 | 69 6e 20 74 68 65 20 6f |l logic |in the o|
|000034c0| 70 74 69 6d 69 7a 61 74 | 69 6f 6e 20 6d 6f 64 75 |ptimizat|ion modu|
|000034d0| 6c 65 2c 20 74 68 65 0a | 58 20 20 20 20 70 69 70 |le, the.|X pip|
|000034e0| 65 6c 69 6e 65 20 63 6f | 6e 74 72 6f 6c 20 64 6f |eline co|ntrol do|
|000034f0| 65 73 6e 27 74 20 61 63 | 74 75 61 6c 6c 79 20 68 |esn't ac|tually h|
|00003500| 61 6e 64 20 6f 76 65 72 | 20 62 69 67 2d 61 72 72 |and over| big-arr|
|00003510| 61 79 20 70 6f 69 6e 74 | 65 72 73 2c 20 62 75 74 |ay point|ers, but|
|00003520| 20 72 61 74 68 65 72 0a | 58 20 20 20 20 61 6e 20 | rather.|X an |
|00003530| 22 69 74 65 72 61 74 6f | 72 22 3a 20 61 20 66 75 |"iterato|r": a fu|
|00003540| 6e 63 74 69 6f 6e 20 77 | 68 69 63 68 20 6b 6e 6f |nction w|hich kno|
|00003550| 77 73 20 68 6f 77 20 74 | 6f 20 73 63 61 6e 20 74 |ws how t|o scan t|
|00003560| 68 65 20 73 74 6f 72 65 | 64 20 69 6d 61 67 65 2e |he store|d image.|
|00003570| 0a 58 20 20 20 20 28 54 | 68 69 73 20 68 69 64 65 |.X (T|his hide|
|00003580| 73 20 74 68 65 20 64 65 | 74 61 69 6c 73 20 6f 66 |s the de|tails of|
|00003590| 20 74 68 65 20 70 61 72 | 61 6d 65 74 65 72 20 6f | the par|ameter o|
|000035a0| 70 74 69 6d 69 7a 61 74 | 69 6f 6e 20 61 6c 67 6f |ptimizat|ion algo|
|000035b0| 72 69 74 68 6d 2e 29 0a | 58 0a 58 20 20 20 20 54 |rithm.).|X.X T|
|000035c0| 68 65 20 70 72 65 73 65 | 6e 74 20 64 65 73 69 67 |he prese|nt desig|
|000035d0| 6e 20 64 6f 65 73 6e 27 | 74 20 61 6c 6c 6f 77 20 |n doesn'|t allow |
|000035e0| 66 6f 72 20 6d 75 6c 74 | 69 70 6c 65 20 70 61 73 |for mult|iple pas|
|000035f0| 73 65 73 20 61 74 20 65 | 61 72 6c 69 65 72 20 70 |ses at e|arlier p|
|00003600| 6f 69 6e 74 73 0a 58 20 | 20 20 20 69 6e 20 74 68 |oints.X | in th|
|00003610| 65 20 70 69 70 65 6c 69 | 6e 65 2c 20 62 75 74 20 |e pipeli|ne, but |
|00003620| 61 6c 6c 6f 77 69 6e 67 | 20 74 68 61 74 20 77 6f |allowing| that wo|
|00003630| 75 6c 64 20 6f 6e 6c 79 | 20 72 65 71 75 69 72 65 |uld only| require|
|00003640| 20 70 72 6f 76 69 64 69 | 6e 67 20 73 6f 6d 65 0a | providi|ng some.|
|00003650| 58 20 20 20 20 6e 65 77 | 20 70 69 70 65 6c 69 6e |X new| pipelin|
|00003660| 65 20 63 6f 6e 74 72 6f | 6c 20 6d 65 74 68 6f 64 |e contro|l method|
|00003670| 73 3b 20 6e 6f 74 68 69 | 6e 67 20 65 6c 73 65 20 |s; nothi|ng else |
|00003680| 6e 65 65 64 20 63 68 61 | 6e 67 65 2e 0a 58 0a 58 |need cha|nge..X.X|
|00003690| 31 34 2e 20 41 20 6d 65 | 6d 6f 72 79 20 6d 61 6e |14. A me|mory man|
|000036a0| 61 67 65 6d 65 6e 74 20 | 6f 62 6a 65 63 74 2e 20 |agement |object. |
|000036b0| 20 54 68 69 73 20 77 69 | 6c 6c 20 70 72 6f 76 69 | This wi|ll provi|
|000036c0| 64 65 20 6d 65 74 68 6f | 64 73 20 74 6f 20 61 6c |de metho|ds to al|
|000036d0| 6c 6f 63 61 74 65 20 22 | 73 6d 61 6c 6c 22 0a 58 |locate "|small".X|
|000036e0| 20 20 20 20 74 68 69 6e | 67 73 20 61 6e 64 20 22 | thin|gs and "|
|000036f0| 62 69 67 22 20 74 68 69 | 6e 67 73 2e 20 20 53 6d |big" thi|ngs. Sm|
|00003700| 61 6c 6c 20 74 68 69 6e | 67 73 20 68 61 76 65 20 |all thin|gs have |
|00003710| 74 6f 20 66 69 74 20 69 | 6e 20 6d 65 6d 6f 72 79 |to fit i|n memory|
|00003720| 20 61 6e 64 20 79 6f 75 | 20 67 65 74 0a 58 20 20 | and you| get.X |
|00003730| 20 20 62 61 63 6b 20 64 | 69 72 65 63 74 20 70 6f | back d|irect po|
|00003740| 69 6e 74 65 72 73 20 28 | 74 68 69 73 20 63 6f 75 |inters (|this cou|
|00003750| 6c 64 20 62 65 20 68 61 | 6e 64 6c 65 64 20 62 79 |ld be ha|ndled by|
|00003760| 20 64 69 72 65 63 74 20 | 63 61 6c 6c 73 20 74 6f | direct |calls to|
|00003770| 20 6d 61 6c 6c 6f 63 2c | 20 62 75 74 0a 58 20 20 | malloc,| but.X |
|00003780| 20 20 69 74 27 73 20 63 | 6c 65 61 6e 65 72 20 6e | it's c|leaner n|
|00003790| 6f 74 20 74 6f 20 61 73 | 73 75 6d 65 20 6d 61 6c |ot to as|sume mal|
|000037a0| 6c 6f 63 20 69 73 20 74 | 68 65 20 72 69 67 68 74 |loc is t|he right|
|000037b0| 20 72 6f 75 74 69 6e 65 | 29 2e 20 20 22 42 69 67 | routine|). "Big|
|000037c0| 22 20 74 68 69 6e 67 73 | 0a 58 20 20 20 20 6d 65 |" things|.X me|
|000037d0| 61 6e 20 62 75 66 66 65 | 72 65 64 20 69 6d 61 67 |an buffe|red imag|
|000037e0| 65 73 20 66 6f 72 20 6d | 75 6c 74 69 70 6c 65 20 |es for m|ultiple |
|000037f0| 70 61 73 73 65 73 2c 20 | 6e 6f 6e 69 6e 74 65 72 |passes, |noninter|
|00003800| 6c 65 61 76 65 64 20 6f | 75 74 70 75 74 2c 20 65 |leaved o|utput, e|
|00003810| 74 63 2e 0a 58 20 20 20 | 20 49 6e 20 74 68 69 73 |tc..X | In this|
|00003820| 20 63 61 73 65 20 74 68 | 65 20 6d 65 6d 6f 72 79 | case th|e memory|
|00003830| 20 6d 61 6e 61 67 65 6d | 65 6e 74 20 6f 62 6a 65 | managem|ent obje|
|00003840| 63 74 20 77 69 6c 6c 20 | 67 69 76 65 20 79 6f 75 |ct will |give you|
|00003850| 20 72 6f 6f 6d 20 66 6f | 72 20 61 20 66 65 77 20 | room fo|r a few |
|00003860| 4d 43 55 0a 58 20 20 20 | 20 72 6f 77 73 20 61 6e |MCU.X | rows an|
|00003870| 64 20 79 6f 75 20 68 61 | 76 65 20 74 6f 20 61 73 |d you ha|ve to as|
|00003880| 6b 20 66 6f 72 20 61 63 | 63 65 73 73 20 74 6f 20 |k for ac|cess to |
|00003890| 74 68 65 20 6e 65 78 74 | 20 66 65 77 3b 20 64 75 |the next| few; du|
|000038a0| 6d 70 69 6e 67 20 61 6e | 64 20 72 65 6c 6f 61 64 |mping an|d reload|
|000038b0| 69 6e 67 0a 58 20 20 20 | 20 69 6e 20 61 20 74 65 |ing.X | in a te|
|000038c0| 6d 70 6f 72 61 72 79 20 | 66 69 6c 65 20 77 69 6c |mporary |file wil|
|000038d0| 6c 20 67 6f 20 6f 6e 20 | 62 65 68 69 6e 64 20 74 |l go on |behind t|
|000038e0| 68 65 20 73 63 65 6e 65 | 73 2e 20 20 28 41 6c 6c |he scene|s. (All|
|000038f0| 20 62 69 67 20 6f 62 6a | 65 63 74 73 20 61 72 65 | big obj|ects are|
|00003900| 0a 58 20 20 20 20 69 6d | 61 67 65 20 61 72 72 61 |.X im|age arra|
|00003910| 79 73 20 63 6f 6e 74 61 | 69 6e 69 6e 67 20 65 69 |ys conta|ining ei|
|00003920| 74 68 65 72 20 73 61 6d | 70 6c 65 73 20 6f 72 20 |ther sam|ples or |
|00003930| 63 6f 65 66 66 69 63 69 | 65 6e 74 73 2c 20 61 6e |coeffici|ents, an|
|00003940| 64 20 77 69 6c 6c 20 62 | 65 0a 58 20 20 20 20 73 |d will b|e.X s|
|00003950| 63 61 6e 6e 65 64 20 74 | 6f 70 2d 74 6f 2d 62 6f |canned t|op-to-bo|
|00003960| 74 74 6f 6d 20 73 6f 6d | 65 20 6e 75 6d 62 65 72 |ttom som|e number|
|00003970| 20 6f 66 20 74 69 6d 65 | 73 2c 20 73 6f 20 77 65 | of time|s, so we|
|00003980| 20 63 61 6e 20 61 70 70 | 6c 79 20 74 68 69 73 20 | can app|ly this |
|00003990| 61 63 63 65 73 73 0a 58 | 20 20 20 20 6d 6f 64 65 |access.X| mode|
|000039a0| 6c 20 65 61 73 69 6c 79 | 2e 29 20 20 4f 6e 20 61 |l easily|.) On a|
|000039b0| 20 70 6c 61 74 66 6f 72 | 6d 20 77 69 74 68 20 76 | platfor|m with v|
|000039c0| 69 72 74 75 61 6c 20 6d | 65 6d 6f 72 79 2c 20 74 |irtual m|emory, t|
|000039d0| 68 65 20 6d 65 6d 6f 72 | 79 20 6d 61 6e 61 67 65 |he memor|y manage|
|000039e0| 72 20 63 61 6e 0a 58 20 | 20 20 20 74 72 65 61 74 |r can.X | treat|
|000039f0| 20 73 6d 61 6c 6c 20 61 | 6e 64 20 62 69 67 20 74 | small a|nd big t|
|00003a00| 68 69 6e 67 73 20 61 6c | 69 6b 65 3a 20 6a 75 73 |hings al|ike: jus|
|00003a10| 74 20 6d 61 6c 6c 6f 63 | 20 75 70 20 65 6e 6f 75 |t malloc| up enou|
|00003a20| 67 68 20 76 69 72 74 75 | 61 6c 20 6d 65 6d 6f 72 |gh virtu|al memor|
|00003a30| 79 20 66 6f 72 0a 58 20 | 20 20 20 74 68 65 20 77 |y for.X | the w|
|00003a40| 68 6f 6c 65 20 69 6d 61 | 67 65 2c 20 61 6e 64 20 |hole ima|ge, and |
|00003a50| 6c 65 74 20 74 68 65 20 | 6f 70 65 72 61 74 69 6e |let the |operatin|
|00003a60| 67 20 73 79 73 74 65 6d | 20 77 6f 72 72 79 20 61 |g system| worry a|
|00003a70| 62 6f 75 74 20 73 77 61 | 70 70 69 6e 67 20 74 68 |bout swa|pping th|
|00003a80| 65 0a 58 20 20 20 20 69 | 6d 61 67 65 20 74 6f 20 |e.X i|mage to |
|00003a90| 64 69 73 6b 2e 0a 58 0a | 58 20 20 20 20 4d 6f 73 |disk..X.|X Mos|
|00003aa0| 74 20 6f 66 20 74 68 65 | 20 61 63 74 75 61 6c 20 |t of the| actual |
|00003ab0| 63 61 6c 6c 73 20 6f 6e | 20 74 68 65 20 6d 65 6d |calls on| the mem|
|00003ac0| 6f 72 79 20 6d 61 6e 61 | 67 65 72 20 77 69 6c 6c |ory mana|ger will|
|00003ad0| 20 62 65 20 6d 61 64 65 | 20 66 72 6f 6d 20 70 69 | be made| from pi|
|00003ae0| 70 65 6c 69 6e 65 0a 58 | 20 20 20 20 63 6f 6e 74 |peline.X| cont|
|00003af0| 72 6f 6c 20 6f 62 6a 65 | 63 74 73 3b 20 63 68 61 |rol obje|cts; cha|
|00003b00| 6e 67 69 6e 67 20 61 6e | 79 20 64 61 74 61 20 69 |nging an|y data i|
|00003b10| 74 65 6d 20 66 72 6f 6d | 20 22 73 6d 61 6c 6c 22 |tem from| "small"|
|00003b20| 20 74 6f 20 22 62 69 67 | 22 20 73 74 61 74 75 73 | to "big|" status|
|00003b30| 20 77 6f 75 6c 64 0a 58 | 20 20 20 20 72 65 71 75 | would.X| requ|
|00003b40| 69 72 65 20 61 20 6e 65 | 77 20 70 69 70 65 6c 69 |ire a ne|w pipeli|
|00003b50| 6e 65 20 63 6f 6e 74 72 | 6f 6c 20 6f 62 6a 65 63 |ne contr|ol objec|
|00003b60| 74 2c 20 73 69 6e 63 65 | 20 69 74 20 77 69 6c 6c |t, since| it will|
|00003b70| 20 63 6f 6e 74 61 69 6e | 20 74 68 65 20 6c 6f 67 | contain| the log|
|00003b80| 69 63 20 74 6f 0a 58 20 | 20 20 20 61 73 6b 20 66 |ic to.X | ask f|
|00003b90| 6f 72 20 61 20 6e 65 77 | 20 63 68 75 6e 6b 20 6f |or a new| chunk o|
|00003ba0| 66 20 61 20 62 69 67 20 | 74 68 69 6e 67 2e 20 20 |f a big |thing. |
|00003bb0| 54 68 75 73 2c 20 6f 6e | 65 20 77 61 79 20 69 6e |Thus, on|e way in|
|00003bc0| 20 77 68 69 63 68 20 70 | 69 70 65 6c 69 6e 65 0a | which p|ipeline.|
|00003bd0| 58 20 20 20 20 63 6f 6e | 74 72 6f 6c 6c 65 72 73 |X con|trollers|
|00003be0| 20 77 69 6c 6c 20 76 61 | 72 79 20 69 73 20 69 6e | will va|ry is in|
|00003bf0| 20 77 68 69 63 68 20 73 | 74 72 75 63 74 75 72 65 | which s|tructure|
|00003c00| 73 20 74 68 65 79 20 74 | 72 65 61 74 20 61 73 20 |s they t|reat as |
|00003c10| 62 69 67 2e 0a 58 0a 58 | 20 20 20 20 54 68 65 20 |big..X.X| The |
|00003c20| 6d 65 6d 6f 72 79 20 6d | 61 6e 61 67 65 72 20 77 |memory m|anager w|
|00003c30| 69 6c 6c 20 6e 65 65 64 | 20 74 6f 20 62 65 20 74 |ill need| to be t|
|00003c40| 6f 6c 64 20 72 6f 75 67 | 68 6c 79 20 68 6f 77 20 |old roug|hly how |
|00003c50| 6d 75 63 68 20 73 70 61 | 63 65 20 69 73 20 67 6f |much spa|ce is go|
|00003c60| 69 6e 67 20 74 6f 0a 58 | 20 20 20 20 62 65 20 72 |ing to.X| be r|
|00003c70| 65 71 75 65 73 74 65 64 | 20 6f 76 65 72 61 6c 6c |equested| overall|
|00003c80| 2c 20 73 6f 20 74 68 61 | 74 20 69 74 20 63 61 6e |, so tha|t it can|
|00003c90| 20 66 69 67 75 72 65 20 | 6f 75 74 20 68 6f 77 20 | figure |out how |
|00003ca0| 62 69 67 20 61 20 62 75 | 66 66 65 72 20 69 73 20 |big a bu|ffer is |
|00003cb0| 73 61 66 65 0a 58 20 20 | 20 20 74 6f 20 61 6c 6c |safe.X | to all|
|00003cc0| 6f 63 61 74 65 20 66 6f | 72 20 61 20 22 62 69 67 |ocate fo|r a "big|
|00003cd0| 22 20 6f 62 6a 65 63 74 | 2e 20 20 28 49 66 20 69 |" object|. (If i|
|00003ce0| 74 20 68 61 70 70 65 6e | 73 20 74 68 61 74 20 79 |t happen|s that y|
|00003cf0| 6f 75 20 61 72 65 20 64 | 65 61 6c 69 6e 67 20 77 |ou are d|ealing w|
|00003d00| 69 74 68 0a 58 20 20 20 | 20 61 20 73 6d 61 6c 6c |ith.X | a small|
|00003d10| 20 69 6d 61 67 65 2c 20 | 79 6f 75 27 64 20 6c 69 | image, |you'd li|
|00003d20| 6b 65 20 74 6f 20 64 65 | 63 69 64 65 20 74 6f 20 |ke to de|cide to |
|00003d30| 6b 65 65 70 20 69 74 20 | 61 6c 6c 20 69 6e 20 6d |keep it |all in m|
|00003d40| 65 6d 6f 72 79 21 29 20 | 20 54 68 65 20 6d 6f 73 |emory!) | The mos|
|00003d50| 74 0a 58 20 20 20 20 66 | 6c 65 78 69 62 6c 65 20 |t.X f|lexible |
|00003d60| 77 61 79 20 6f 66 20 64 | 6f 69 6e 67 20 74 68 69 |way of d|oing thi|
|00003d70| 73 20 69 73 20 74 6f 20 | 64 69 76 69 64 65 20 61 |s is to |divide a|
|00003d80| 6c 6c 6f 63 61 74 69 6f | 6e 20 6f 66 20 22 62 69 |llocatio|n of "bi|
|00003d90| 67 22 20 6f 62 6a 65 63 | 74 73 20 69 6e 74 6f 0a |g" objec|ts into.|
|00003da0| 58 20 20 20 20 74 77 6f | 20 73 74 65 70 73 2e 20 |X two| steps. |
|00003db0| 20 46 69 72 73 74 2c 20 | 74 68 65 72 65 20 77 69 | First, |there wi|
|00003dc0| 6c 6c 20 62 65 20 6f 6e | 65 20 6f 72 20 6d 6f 72 |ll be on|e or mor|
|00003dd0| 65 20 22 72 65 71 75 65 | 73 74 22 20 63 61 6c 6c |e "reque|st" call|
|00003de0| 73 20 74 68 61 74 20 69 | 6e 64 69 63 61 74 65 0a |s that i|ndicate.|
|00003df0| 58 20 20 20 20 74 68 65 | 20 64 65 73 69 72 65 64 |X the| desired|
|00003e00| 20 6f 62 6a 65 63 74 20 | 73 69 7a 65 73 3b 20 74 | object |sizes; t|
|00003e10| 68 65 6e 20 61 6e 20 22 | 69 6e 73 74 61 6e 74 69 |hen an "|instanti|
|00003e20| 61 74 65 22 20 63 61 6c | 6c 20 63 61 75 73 65 73 |ate" cal|l causes|
|00003e30| 20 74 68 65 20 6d 65 6d | 6f 72 79 0a 58 20 20 20 | the mem|ory.X |
|00003e40| 20 6d 61 6e 61 67 65 72 | 20 74 6f 20 61 63 74 75 | manager| to actu|
|00003e50| 61 6c 6c 79 20 63 6f 6e | 73 74 72 75 63 74 20 74 |ally con|struct t|
|00003e60| 68 65 20 6f 62 6a 65 63 | 74 73 2e 20 20 54 68 65 |he objec|ts. The|
|00003e70| 20 69 6e 73 74 61 6e 74 | 69 61 74 69 6f 6e 20 6d | instant|iation m|
|00003e80| 75 73 74 20 6f 63 63 75 | 72 0a 58 20 20 20 20 62 |ust occu|r.X b|
|00003e90| 65 66 6f 72 65 20 74 68 | 65 20 63 6f 6e 74 65 6e |efore th|e conten|
|00003ea0| 74 73 20 6f 66 20 61 6e | 79 20 62 69 67 20 6f 62 |ts of an|y big ob|
|00003eb0| 6a 65 63 74 20 63 61 6e | 20 62 65 20 61 63 63 65 |ject can| be acce|
|00003ec0| 73 73 65 64 2e 0a 58 0a | 58 20 20 20 20 46 6f 72 |ssed..X.|X For|
|00003ed0| 20 38 30 78 38 36 20 43 | 50 55 73 2c 20 77 65 20 | 80x86 C|PUs, we |
|00003ee0| 77 6f 75 6c 64 20 6c 69 | 6b 65 20 74 68 65 20 63 |would li|ke the c|
|00003ef0| 6f 64 65 20 74 6f 20 62 | 65 20 63 6f 6d 70 69 6c |ode to b|e compil|
|00003f00| 61 62 6c 65 20 75 6e 64 | 65 72 20 73 6d 61 6c 6c |able und|er small|
|00003f10| 20 6f 72 0a 58 20 20 20 | 20 6d 65 64 69 75 6d 20 | or.X | medium |
|00003f20| 6d 6f 64 65 6c 2c 20 6d | 65 61 6e 69 6e 67 20 74 |model, m|eaning t|
|00003f30| 68 61 74 20 70 6f 69 6e | 74 65 72 73 20 61 72 65 |hat poin|ters are|
|00003f40| 20 31 36 20 62 69 74 73 | 20 75 6e 6c 65 73 73 20 | 16 bits| unless |
|00003f50| 65 78 70 6c 69 63 69 74 | 6c 79 20 64 65 63 6c 61 |explicit|ly decla|
|00003f60| 72 65 64 0a 58 20 20 20 | 20 46 41 52 2e 20 20 48 |red.X | FAR. H|
|00003f70| 65 6e 63 65 20 73 70 61 | 63 65 20 61 6c 6c 6f 63 |ence spa|ce alloc|
|00003f80| 61 74 65 64 20 62 79 20 | 74 68 65 20 22 73 6d 61 |ated by |the "sma|
|00003f90| 6c 6c 22 20 61 6c 6c 6f | 63 61 74 6f 72 20 6d 75 |ll" allo|cator mu|
|00003fa0| 73 74 20 66 69 74 20 69 | 6e 74 6f 20 74 68 65 0a |st fit i|nto the.|
|00003fb0| 58 20 20 20 20 36 34 4b | 62 20 64 65 66 61 75 6c |X 64K|b defaul|
|00003fc0| 74 20 64 61 74 61 20 73 | 65 67 6d 65 6e 74 2c 20 |t data s|egment, |
|00003fd0| 61 6c 6f 6e 67 20 77 69 | 74 68 20 73 74 61 63 6b |along wi|th stack|
|00003fe0| 20 73 70 61 63 65 20 61 | 6e 64 20 67 6c 6f 62 61 | space a|nd globa|
|00003ff0| 6c 2f 73 74 61 74 69 63 | 20 64 61 74 61 2e 0a 58 |l/static| data..X|
|00004000| 20 20 20 20 46 6f 72 20 | 6e 6f 72 6d 61 6c 20 4a | For |normal J|
|00004010| 50 45 47 20 6f 70 65 72 | 61 74 69 6f 6e 73 20 77 |PEG oper|ations w|
|00004020| 65 20 73 65 65 6d 20 74 | 6f 20 6e 65 65 64 20 6f |e seem t|o need o|
|00004030| 6e 6c 79 20 61 62 6f 75 | 74 20 33 32 4b 62 20 6f |nly abou|t 32Kb o|
|00004040| 66 20 73 75 63 68 20 73 | 70 61 63 65 2c 0a 58 20 |f such s|pace,.X |
|00004050| 20 20 20 73 6f 20 77 65 | 20 61 72 65 20 77 69 74 | so we| are wit|
|00004060| 68 69 6e 20 74 68 65 20 | 74 61 72 67 65 74 20 28 |hin the |target (|
|00004070| 61 6e 64 20 68 61 76 65 | 20 61 20 72 65 61 73 6f |and have| a reaso|
|00004080| 6e 61 62 6c 65 20 73 6c | 6f 70 20 66 6f 72 20 74 |nable sl|op for t|
|00004090| 68 65 20 6e 65 65 64 73 | 20 6f 66 0a 58 20 20 20 |he needs| of.X |
|000040a0| 20 61 20 73 75 72 72 6f | 75 6e 64 69 6e 67 20 61 | a surro|unding a|
|000040b0| 70 70 6c 69 63 61 74 69 | 6f 6e 20 70 72 6f 67 72 |pplicati|on progr|
|000040c0| 61 6d 29 2e 20 20 48 6f | 77 65 76 65 72 2c 20 73 |am). Ho|wever, s|
|000040d0| 6f 6d 65 20 63 6f 6c 6f | 72 20 71 75 61 6e 74 69 |ome colo|r quanti|
|000040e0| 7a 61 74 69 6f 6e 0a 58 | 20 20 20 20 61 6c 67 6f |zation.X| algo|
|000040f0| 72 69 74 68 6d 73 20 6e | 65 65 64 20 36 34 4b 62 |rithms n|eed 64Kb|
|00004100| 20 6f 72 20 6d 6f 72 65 | 20 6f 66 20 61 6c 6c 2d | or more| of all-|
|00004110| 69 6e 2d 6d 65 6d 6f 72 | 79 20 73 70 61 63 65 20 |in-memor|y space |
|00004120| 69 6e 20 6f 72 64 65 72 | 20 74 6f 20 63 72 65 61 |in order| to crea|
|00004130| 74 65 0a 58 20 20 20 20 | 63 6f 6c 6f 72 20 68 69 |te.X |color hi|
|00004140| 73 74 6f 67 72 61 6d 73 | 2e 20 20 46 6f 72 20 74 |stograms|. For t|
|00004150| 68 69 73 20 70 75 72 70 | 6f 73 65 2c 20 77 65 20 |his purp|ose, we |
|00004160| 77 69 6c 6c 20 61 6c 73 | 6f 20 73 75 70 70 6f 72 |will als|o suppor|
|00004170| 74 20 22 6d 65 64 69 75 | 6d 22 20 73 69 7a 65 0a |t "mediu|m" size.|
|00004180| 58 20 20 20 20 74 68 69 | 6e 67 73 2e 20 20 54 68 |X thi|ngs. Th|
|00004190| 65 73 65 20 61 72 65 20 | 73 65 6d 61 6e 74 69 63 |ese are |semantic|
|000041a0| 61 6c 6c 79 20 74 68 65 | 20 73 61 6d 65 20 61 73 |ally the| same as|
|000041b0| 20 22 73 6d 61 6c 6c 22 | 20 74 68 69 6e 67 73 20 | "small"| things |
|000041c0| 62 75 74 20 61 72 65 0a | 58 20 20 20 20 72 65 66 |but are.|X ref|
|000041d0| 65 72 65 6e 63 65 64 20 | 74 68 72 6f 75 67 68 20 |erenced |through |
|000041e0| 46 41 52 20 70 6f 69 6e | 74 65 72 73 2e 0a 58 0a |FAR poin|ters..X.|
|000041f0| 58 20 20 20 20 54 68 65 | 20 66 6f 6c 6c 6f 77 69 |X The| followi|
|00004200| 6e 67 20 6d 65 74 68 6f | 64 73 20 77 69 6c 6c 20 |ng metho|ds will |
|00004210| 62 65 20 6e 65 65 64 65 | 64 3a 0a 58 09 61 6c 6c |be neede|d:.X.all|
|00004220| 6f 63 5f 73 6d 61 6c 6c | 3a 09 61 6c 6c 6f 63 61 |oc_small|:.alloca|
|00004230| 74 65 20 61 6e 20 6f 62 | 6a 65 63 74 20 6f 66 20 |te an ob|ject of |
|00004240| 67 69 76 65 6e 20 73 69 | 7a 65 3b 20 75 73 65 20 |given si|ze; use |
|00004250| 66 6f 72 20 61 6e 79 20 | 72 61 6e 64 6f 6d 0a 58 |for any |random.X|
|00004260| 09 09 09 64 61 74 61 20 | 74 68 61 74 27 73 20 6e |...data |that's n|
|00004270| 6f 74 20 61 6e 20 69 6d | 61 67 65 20 61 72 72 61 |ot an im|age arra|
|00004280| 79 2e 0a 58 09 66 72 65 | 65 5f 73 6d 61 6c 6c 3a |y..X.fre|e_small:|
|00004290| 09 72 65 6c 65 61 73 65 | 20 73 61 6d 65 2e 0a 58 |.release| same..X|
|000042a0| 09 61 6c 6c 6f 63 5f 6d | 65 64 69 75 6d 3a 09 6c |.alloc_m|edium:.l|
|000042b0| 69 6b 65 20 61 6c 6c 6f | 63 5f 73 6d 61 6c 6c 2c |ike allo|c_small,|
|000042c0| 20 62 75 74 20 72 65 74 | 75 72 6e 73 20 61 20 46 | but ret|urns a F|
|000042d0| 41 52 20 70 6f 69 6e 74 | 65 72 2e 20 20 55 73 65 |AR point|er. Use|
|000042e0| 20 66 6f 72 0a 58 09 09 | 09 61 6e 79 20 6f 62 6a | for.X..|.any obj|
|000042f0| 65 63 74 20 62 69 67 67 | 65 72 20 74 68 61 6e 20 |ect bigg|er than |
|00004300| 61 20 63 6f 75 70 6c 65 | 20 6b 69 6c 6f 62 79 74 |a couple| kilobyt|
|00004310| 65 73 2e 0a 58 09 66 72 | 65 65 5f 6d 65 64 69 75 |es..X.fr|ee_mediu|
|00004320| 6d 3a 09 72 65 6c 65 61 | 73 65 20 73 61 6d 65 2e |m:.relea|se same.|
|00004330| 0a 58 09 61 6c 6c 6f 63 | 5f 73 6d 61 6c 6c 5f 73 |.X.alloc|_small_s|
|00004340| 61 72 72 61 79 3a 20 63 | 6f 6e 73 74 72 75 63 74 |array: c|onstruct|
|00004350| 20 61 6e 20 61 6c 6c 2d | 69 6e 2d 6d 65 6d 6f 72 | an all-|in-memor|
|00004360| 79 20 69 6d 61 67 65 20 | 73 61 6d 70 6c 65 20 61 |y image |sample a|
|00004370| 72 72 61 79 2e 0a 58 09 | 66 72 65 65 5f 73 6d 61 |rray..X.|free_sma|
|00004380| 6c 6c 5f 73 61 72 72 61 | 79 3a 20 20 72 65 6c 65 |ll_sarra|y: rele|
|00004390| 61 73 65 20 73 61 6d 65 | 2e 0a 58 09 61 6c 6c 6f |ase same|..X.allo|
|000043a0| 63 5f 73 6d 61 6c 6c 5f | 62 61 72 72 61 79 2c 0a |c_small_|barray,.|
|000043b0| 58 09 66 72 65 65 5f 73 | 6d 61 6c 6c 5f 62 61 72 |X.free_s|mall_bar|
|000043c0| 72 61 79 3a 20 20 64 69 | 74 74 6f 20 66 6f 72 20 |ray: di|tto for |
|000043d0| 62 6c 6f 63 6b 20 28 63 | 6f 65 66 66 69 63 69 65 |block (c|oefficie|
|000043e0| 6e 74 29 20 61 72 72 61 | 79 73 2e 0a 58 09 72 65 |nt) arra|ys..X.re|
|000043f0| 71 75 65 73 74 5f 62 69 | 67 5f 73 61 72 72 61 79 |quest_bi|g_sarray|
|00004400| 3a 20 20 72 65 71 75 65 | 73 74 20 61 20 76 69 72 |: reque|st a vir|
|00004410| 74 75 61 6c 20 69 6d 61 | 67 65 20 73 61 6d 70 6c |tual ima|ge sampl|
|00004420| 65 20 61 72 72 61 79 2e | 20 20 54 68 65 20 73 69 |e array.| The si|
|00004430| 7a 65 0a 58 09 09 09 20 | 20 20 20 20 6f 66 20 74 |ze.X... | of t|
|00004440| 68 65 20 69 6e 2d 6d 65 | 6d 6f 72 79 20 62 75 66 |he in-me|mory buf|
|00004450| 66 65 72 20 77 69 6c 6c | 20 62 65 20 64 65 74 65 |fer will| be dete|
|00004460| 72 6d 69 6e 65 64 20 62 | 79 20 74 68 65 0a 58 09 |rmined b|y the.X.|
|00004470| 09 09 20 20 20 20 20 6d | 65 6d 6f 72 79 20 6d 61 |.. m|emory ma|
|00004480| 6e 61 67 65 72 2c 20 62 | 75 74 20 69 74 20 77 69 |nager, b|ut it wi|
|00004490| 6c 6c 20 61 6c 77 61 79 | 73 20 62 65 20 61 20 6d |ll alway|s be a m|
|000044a0| 75 6c 74 69 70 6c 65 0a | 58 09 09 09 20 20 20 20 |ultiple.|X... |
|000044b0| 20 6f 66 20 74 68 65 20 | 70 61 73 73 65 64 2d 69 | of the |passed-i|
|000044c0| 6e 20 4d 43 55 20 68 65 | 69 67 68 74 2e 0a 58 09 |n MCU he|ight..X.|
|000044d0| 72 65 71 75 65 73 74 5f | 62 69 67 5f 62 61 72 72 |request_|big_barr|
|000044e0| 61 79 3a 20 20 64 69 74 | 74 6f 20 66 6f 72 20 62 |ay: dit|to for b|
|000044f0| 6c 6f 63 6b 20 28 63 6f | 65 66 66 69 63 69 65 6e |lock (co|efficien|
|00004500| 74 29 20 61 72 72 61 79 | 73 2e 0a 58 09 61 6c 6c |t) array|s..X.all|
|00004510| 6f 63 5f 62 69 67 5f 61 | 72 72 61 79 73 3a 20 20 |oc_big_a|rrays: |
|00004520| 69 6e 73 74 61 6e 74 69 | 61 74 65 20 61 6c 6c 20 |instanti|ate all |
|00004530| 74 68 65 20 62 69 67 20 | 61 72 72 61 79 73 20 70 |the big |arrays p|
|00004540| 72 65 76 69 6f 75 73 6c | 79 20 72 65 71 75 65 73 |reviousl|y reques|
|00004550| 74 65 64 2e 0a 58 09 09 | 09 20 20 20 54 68 69 73 |ted..X..|. This|
|00004560| 20 63 61 6c 6c 20 77 69 | 6c 6c 20 61 6c 73 6f 20 | call wi|ll also |
|00004570| 70 61 73 73 20 73 6f 6d | 65 20 69 6e 66 6f 20 61 |pass som|e info a|
|00004580| 62 6f 75 74 20 66 75 74 | 75 72 65 0a 58 09 09 09 |bout fut|ure.X...|
|00004590| 20 20 20 6d 65 6d 6f 72 | 79 20 64 65 6d 61 6e 64 | memor|y demand|
|000045a0| 73 2c 20 73 6f 20 74 68 | 61 74 20 74 68 65 20 6d |s, so th|at the m|
|000045b0| 65 6d 6f 72 79 20 6d 61 | 6e 61 67 65 72 20 63 61 |emory ma|nager ca|
|000045c0| 6e 0a 58 09 09 09 20 20 | 20 66 69 67 75 72 65 20 |n.X... | figure |
|000045d0| 6f 75 74 20 68 6f 77 20 | 6d 75 63 68 20 73 70 61 |out how |much spa|
|000045e0| 63 65 20 74 6f 20 6c 65 | 61 76 65 20 75 6e 61 6c |ce to le|ave unal|
|000045f0| 6c 6f 63 61 74 65 64 2e | 0a 58 09 61 63 63 65 73 |located.|.X.acces|
|00004600| 73 5f 62 69 67 5f 73 61 | 72 72 61 79 3a 20 6f 62 |s_big_sa|rray: ob|
|00004610| 74 61 69 6e 20 61 63 63 | 65 73 73 20 74 6f 20 61 |tain acc|ess to a|
|00004620| 20 73 70 65 63 69 66 69 | 65 64 20 70 6f 72 74 69 | specifi|ed porti|
|00004630| 6f 6e 20 6f 66 20 61 20 | 76 69 72 74 75 61 6c 0a |on of a |virtual.|
|00004640| 58 09 09 09 20 20 20 69 | 6d 61 67 65 20 73 61 6d |X... i|mage sam|
|00004650| 70 6c 65 20 61 72 72 61 | 79 2e 0a 58 09 66 72 65 |ple arra|y..X.fre|
|00004660| 65 5f 62 69 67 5f 73 61 | 72 72 61 79 3a 20 20 20 |e_big_sa|rray: |
|00004670| 72 65 6c 65 61 73 65 20 | 61 20 76 69 72 74 75 61 |release |a virtua|
|00004680| 6c 20 73 61 6d 70 6c 65 | 20 61 72 72 61 79 2e 0a |l sample| array..|
|00004690| 58 09 61 63 63 65 73 73 | 5f 62 69 67 5f 62 61 72 |X.access|_big_bar|
|000046a0| 72 61 79 2c 0a 58 09 66 | 72 65 65 5f 62 69 67 5f |ray,.X.f|ree_big_|
|000046b0| 62 61 72 72 61 79 3a 20 | 20 20 64 69 74 74 6f 20 |barray: | ditto |
|000046c0| 66 6f 72 20 62 6c 6f 63 | 6b 20 28 63 6f 65 66 66 |for bloc|k (coeff|
|000046d0| 69 63 69 65 6e 74 29 20 | 61 72 72 61 79 73 2e 0a |icient) |arrays..|
|000046e0| 58 09 66 72 65 65 5f 61 | 6c 6c 3a 09 20 20 20 72 |X.free_a|ll:. r|
|000046f0| 65 6c 65 61 73 65 20 61 | 6e 79 20 72 65 6d 61 69 |elease a|ny remai|
|00004700| 6e 69 6e 67 20 73 74 6f | 72 61 67 65 2e 20 20 54 |ning sto|rage. T|
|00004710| 68 69 73 20 69 73 20 63 | 61 6c 6c 65 64 0a 58 09 |his is c|alled.X.|
|00004720| 09 09 20 20 20 62 65 66 | 6f 72 65 20 6e 6f 72 6d |.. bef|ore norm|
|00004730| 61 6c 20 6f 72 20 65 72 | 72 6f 72 20 74 65 72 6d |al or er|ror term|
|00004740| 69 6e 61 74 69 6f 6e 3b | 20 74 68 65 20 6d 61 69 |ination;| the mai|
|00004750| 6e 20 72 65 61 73 6f 6e | 0a 58 09 09 09 20 20 20 |n reason|.X... |
|00004760| 77 68 79 20 69 74 20 6d | 75 73 74 20 65 78 69 73 |why it m|ust exis|
|00004770| 74 20 69 73 20 74 6f 20 | 65 6e 73 75 72 65 20 74 |t is to |ensure t|
|00004780| 68 61 74 20 61 6e 79 20 | 74 65 6d 70 6f 72 61 72 |hat any |temporar|
|00004790| 79 0a 58 09 09 09 20 20 | 20 66 69 6c 65 73 20 77 |y.X... | files w|
|000047a0| 69 6c 6c 20 62 65 20 64 | 65 6c 65 74 65 64 20 75 |ill be d|eleted u|
|000047b0| 70 6f 6e 20 65 72 72 6f | 72 20 74 65 72 6d 69 6e |pon erro|r termin|
|000047c0| 61 74 69 6f 6e 2e 0a 58 | 0a 58 20 20 20 20 61 6c |ation..X|.X al|
|000047d0| 6c 6f 63 5f 62 69 67 5f | 61 72 72 61 79 73 20 77 |loc_big_|arrays w|
|000047e0| 69 6c 6c 20 62 65 20 63 | 61 6c 6c 65 64 20 62 79 |ill be c|alled by|
|000047f0| 20 74 68 65 20 70 69 70 | 65 6c 69 6e 65 20 63 6f | the pip|eline co|
|00004800| 6e 74 72 6f 6c 6c 65 72 | 2c 20 77 68 69 63 68 20 |ntroller|, which |
|00004810| 64 6f 65 73 0a 58 20 20 | 20 20 6d 6f 73 74 20 6f |does.X | most o|
|00004820| 66 20 74 68 65 20 6d 65 | 6d 6f 72 79 20 61 6c 6c |f the me|mory all|
|00004830| 6f 63 61 74 69 6f 6e 20 | 61 6e 79 77 61 79 2e 20 |ocation |anyway. |
|00004840| 20 54 68 65 20 6f 6e 6c | 79 20 72 65 61 73 6f 6e | The onl|y reason|
|00004850| 20 66 6f 72 20 68 61 76 | 69 6e 67 20 73 65 70 61 | for hav|ing sepa|
|00004860| 72 61 74 65 0a 58 20 20 | 20 20 72 65 71 75 65 73 |rate.X | reques|
|00004870| 74 20 63 61 6c 6c 73 20 | 69 73 20 74 6f 20 61 6c |t calls |is to al|
|00004880| 6c 6f 77 20 73 6f 6d 65 | 20 6f 66 20 74 68 65 20 |low some| of the |
|00004890| 6f 74 68 65 72 20 6d 6f | 64 75 6c 65 73 20 74 6f |other mo|dules to|
|000048a0| 20 67 65 74 20 62 69 67 | 20 61 72 72 61 79 73 2e | get big| arrays.|
|000048b0| 0a 58 20 20 20 20 54 68 | 65 20 70 69 70 65 6c 69 |.X Th|e pipeli|
|000048c0| 6e 65 20 63 6f 6e 74 72 | 6f 6c 6c 65 72 20 69 73 |ne contr|oller is|
|000048d0| 20 72 65 71 75 69 72 65 | 64 20 74 6f 20 67 69 76 | require|d to giv|
|000048e0| 65 20 61 6e 20 75 70 70 | 65 72 20 62 6f 75 6e 64 |e an upp|er bound|
|000048f0| 20 6f 6e 20 74 6f 74 61 | 6c 20 66 75 74 75 72 65 | on tota|l future|
|00004900| 0a 58 20 20 20 20 73 6d | 61 6c 6c 2d 61 72 72 61 |.X sm|all-arra|
|00004910| 79 20 72 65 71 75 65 73 | 74 73 2c 20 73 6f 20 74 |y reques|ts, so t|
|00004920| 68 61 74 20 74 68 69 73 | 20 73 70 61 63 65 20 63 |hat this| space c|
|00004930| 61 6e 20 62 65 20 64 69 | 73 63 6f 75 6e 74 65 64 |an be di|scounted|
|00004940| 2e 20 20 28 41 20 66 61 | 69 72 6c 79 0a 58 20 20 |. (A fa|irly.X |
|00004950| 20 20 63 6f 6e 73 65 72 | 76 61 74 69 76 65 20 65 | conser|vative e|
|00004960| 73 74 69 6d 61 74 65 20 | 77 69 6c 6c 20 62 65 20 |stimate |will be |
|00004970| 61 64 65 71 75 61 74 65 | 2e 29 20 20 46 75 74 75 |adequate|.) Futu|
|00004980| 72 65 20 73 6d 61 6c 6c | 2d 6f 62 6a 65 63 74 20 |re small|-object |
|00004990| 72 65 71 75 65 73 74 73 | 0a 58 20 20 20 20 61 72 |requests|.X ar|
|000049a0| 65 6e 27 74 20 63 6f 75 | 6e 74 65 64 3b 20 74 68 |en't cou|nted; th|
|000049b0| 65 20 6d 65 6d 6f 72 79 | 20 6d 61 6e 61 67 65 72 |e memory| manager|
|000049c0| 20 68 61 73 20 74 6f 20 | 75 73 65 20 61 20 73 6c | has to |use a sl|
|000049d0| 6f 70 20 66 61 63 74 6f | 72 20 66 6f 72 20 74 68 |op facto|r for th|
|000049e0| 6f 73 65 2e 0a 58 20 20 | 20 20 31 30 4b 20 6f 72 |ose..X | 10K or|
|000049f0| 20 73 6f 20 73 65 65 6d | 73 20 74 6f 20 62 65 20 | so seem|s to be |
|00004a00| 73 75 66 66 69 63 69 65 | 6e 74 2e 20 20 28 49 6e |sufficie|nt. (In|
|00004a10| 20 61 6e 20 38 30 78 38 | 36 2c 20 73 6d 61 6c 6c | an 80x8|6, small|
|00004a20| 20 6f 62 6a 65 63 74 73 | 20 61 72 65 6e 27 74 20 | objects| aren't |
|00004a30| 61 6e 0a 58 20 20 20 20 | 69 73 73 75 65 20 61 6e |an.X |issue an|
|00004a40| 79 77 61 79 2c 20 73 69 | 6e 63 65 20 74 68 65 79 |yway, si|nce they|
|00004a50| 20 64 6f 6e 27 74 20 63 | 6f 6d 70 65 74 65 20 66 | don't c|ompete f|
|00004a60| 6f 72 20 66 61 72 2d 68 | 65 61 70 20 73 70 61 63 |or far-h|eap spac|
|00004a70| 65 2e 20 20 22 4d 65 64 | 69 75 6d 22 2d 73 69 7a |e. "Med|ium"-siz|
|00004a80| 65 0a 58 20 20 20 20 6f | 62 6a 65 63 74 73 20 77 |e.X o|bjects w|
|00004a90| 69 6c 6c 20 68 61 76 65 | 20 74 6f 20 62 65 20 63 |ill have| to be c|
|00004aa0| 6f 75 6e 74 65 64 20 73 | 65 70 61 72 61 74 65 6c |ounted s|eparatel|
|00004ab0| 79 2e 29 0a 58 0a 58 20 | 20 20 20 54 68 65 20 64 |y.).X.X | The d|
|00004ac0| 69 73 74 69 6e 63 74 69 | 6f 6e 20 62 65 74 77 65 |istincti|on betwe|
|00004ad0| 65 6e 20 73 61 6d 70 6c | 65 20 61 6e 64 20 63 6f |en sampl|e and co|
|00004ae0| 65 66 66 69 63 69 65 6e | 74 20 61 72 72 61 79 20 |efficien|t array |
|00004af0| 72 6f 75 74 69 6e 65 73 | 20 69 73 20 61 6e 6e 6f |routines| is anno|
|00004b00| 79 69 6e 67 2c 0a 58 20 | 20 20 20 62 75 74 20 69 |ying,.X | but i|
|00004b10| 74 20 68 61 73 20 74 6f | 20 62 65 20 6d 61 69 6e |t has to| be main|
|00004b20| 74 61 69 6e 65 64 20 66 | 6f 72 20 6d 61 63 68 69 |tained f|or machi|
|00004b30| 6e 65 73 20 69 6e 20 77 | 68 69 63 68 20 22 63 68 |nes in w|hich "ch|
|00004b40| 61 72 20 2a 22 20 69 73 | 20 72 65 70 72 65 73 65 |ar *" is| represe|
|00004b50| 6e 74 65 64 0a 58 20 20 | 20 20 64 69 66 66 65 72 |nted.X | differ|
|00004b60| 65 6e 74 6c 79 20 66 72 | 6f 6d 20 22 69 6e 74 20 |ently fr|om "int |
|00004b70| 2a 22 2e 20 20 4f 6e 20 | 62 79 74 65 2d 61 64 64 |*". On |byte-add|
|00004b80| 72 65 73 73 61 62 6c 65 | 20 6d 61 63 68 69 6e 65 |ressable| machine|
|00004b90| 73 20 73 6f 6d 65 20 6f | 66 20 74 68 65 73 65 0a |s some o|f these.|
|00004ba0| 58 20 20 20 20 6d 65 74 | 68 6f 64 73 20 63 6f 75 |X met|hods cou|
|00004bb0| 6c 64 20 70 65 72 68 61 | 70 73 20 70 6f 69 6e 74 |ld perha|ps point|
|00004bc0| 20 74 6f 20 74 68 65 20 | 73 61 6d 65 20 63 6f 64 | to the |same cod|
|00004bd0| 65 2e 0a 58 0a 58 20 20 | 20 20 54 68 65 20 61 72 |e..X.X | The ar|
|00004be0| 72 61 79 20 72 6f 75 74 | 69 6e 65 73 20 77 69 6c |ray rout|ines wil|
|00004bf0| 6c 20 6f 70 65 72 61 74 | 65 20 6f 6e 20 6f 6e 6c |l operat|e on onl|
|00004c00| 79 20 32 2d 44 20 61 72 | 72 61 79 73 20 28 6f 6e |y 2-D ar|rays (on|
|00004c10| 65 20 63 6f 6d 70 6f 6e | 65 6e 74 20 61 74 20 61 |e compon|ent at a|
|00004c20| 0a 58 20 20 20 20 74 69 | 6d 65 29 2c 20 73 69 6e |.X ti|me), sin|
|00004c30| 63 65 20 64 69 66 66 65 | 72 65 6e 74 20 63 6f 6d |ce diffe|rent com|
|00004c40| 70 6f 6e 65 6e 74 73 20 | 6d 61 79 20 72 65 71 75 |ponents |may requ|
|00004c50| 69 72 65 20 64 69 66 66 | 65 72 65 6e 74 2d 73 69 |ire diff|erent-si|
|00004c60| 7a 65 20 61 72 72 61 79 | 73 2e 0a 58 0a 58 20 20 |ze array|s..X.X |
|00004c70| 20 20 28 54 68 69 73 20 | 6f 62 6a 65 63 74 20 68 | (This |object h|
|00004c80| 69 64 65 73 20 74 68 65 | 20 6b 6e 6f 77 6c 65 64 |ides the| knowled|
|00004c90| 67 65 20 6f 66 20 77 68 | 65 74 68 65 72 20 76 69 |ge of wh|ether vi|
|00004ca0| 72 74 75 61 6c 20 6d 65 | 6d 6f 72 79 20 69 73 20 |rtual me|mory is |
|00004cb0| 61 76 61 69 6c 61 62 6c | 65 2c 0a 58 20 20 20 20 |availabl|e,.X |
|00004cc0| 61 73 20 77 65 6c 6c 20 | 61 73 20 74 68 65 20 61 |as well |as the a|
|00004cd0| 63 74 75 61 6c 20 69 6e | 74 65 72 66 61 63 65 20 |ctual in|terface |
|00004ce0| 74 6f 20 4f 53 20 61 6e | 64 20 6c 69 62 72 61 72 |to OS an|d librar|
|00004cf0| 79 20 73 75 70 70 6f 72 | 74 20 72 6f 75 74 69 6e |y suppor|t routin|
|00004d00| 65 73 2e 29 0a 58 0a 58 | 4e 6f 74 65 20 74 68 61 |es.).X.X|Note tha|
|00004d10| 74 20 61 6e 79 20 67 69 | 76 65 6e 20 69 6d 70 6c |t any gi|ven impl|
|00004d20| 65 6d 65 6e 74 61 74 69 | 6f 6e 20 77 69 6c 6c 20 |ementati|on will |
|00004d30| 70 72 65 73 75 6d 61 62 | 6c 79 20 63 6f 6e 74 61 |presumab|ly conta|
|00004d40| 69 6e 20 6f 6e 6c 79 20 | 6f 6e 65 0a 58 69 6e 73 |in only |one.Xins|
|00004d50| 74 61 6e 74 69 61 74 69 | 6f 6e 20 6f 66 20 69 6e |tantiati|on of in|
|00004d60| 70 75 74 20 66 69 6c 65 | 20 68 65 61 64 65 72 20 |put file| header |
|00004d70| 72 65 61 64 69 6e 67 2c | 20 6f 76 65 72 61 6c 6c |reading,| overall|
|00004d80| 20 63 6f 6e 74 72 6f 6c | 2c 20 75 73 65 72 20 69 | control|, user i|
|00004d90| 6e 74 65 72 66 61 63 65 | 2c 0a 58 61 6e 64 20 6d |nterface|,.Xand m|
|00004da0| 65 6d 6f 72 79 20 6d 61 | 6e 61 67 65 6d 65 6e 74 |emory ma|nagement|
|00004db0| 2e 20 20 54 68 75 73 20 | 74 68 65 73 65 20 63 6f |. Thus |these co|
|00004dc0| 75 6c 64 20 62 65 20 63 | 61 6c 6c 65 64 20 61 73 |uld be c|alled as|
|00004dd0| 20 73 69 6d 70 6c 65 20 | 73 75 62 72 6f 75 74 69 | simple |subrouti|
|00004de0| 6e 65 73 2c 0a 58 77 69 | 74 68 6f 75 74 20 62 6f |nes,.Xwi|thout bo|
|00004df0| 74 68 65 72 69 6e 67 20 | 77 69 74 68 20 61 6e 20 |thering |with an |
|00004e00| 6f 62 6a 65 63 74 20 69 | 6e 64 69 72 65 63 74 69 |object i|ndirecti|
|00004e10| 6f 6e 2e 20 20 54 68 69 | 73 20 69 73 20 65 73 73 |on. Thi|s is ess|
|00004e20| 65 6e 74 69 61 6c 20 66 | 6f 72 20 6f 76 65 72 61 |ential f|or overa|
|00004e30| 6c 6c 0a 58 63 6f 6e 74 | 72 6f 6c 20 28 77 68 69 |ll.Xcont|rol (whi|
|00004e40| 63 68 20 68 61 73 20 74 | 6f 20 69 6e 69 74 69 61 |ch has t|o initia|
|00004e50| 6c 69 7a 65 20 74 68 65 | 20 6f 62 6a 65 63 74 20 |lize the| object |
|00004e60| 73 74 72 75 63 74 75 72 | 65 29 3b 20 66 6f 72 20 |structur|e); for |
|00004e70| 63 6f 6e 73 69 73 74 65 | 6e 63 79 20 77 65 0a 58 |consiste|ncy we.X|
|00004e80| 77 69 6c 6c 20 69 6d 70 | 6f 73 65 20 6f 62 6a 65 |will imp|ose obje|
|00004e90| 63 74 6e 65 73 73 20 6f | 6e 20 74 68 65 20 6f 74 |ctness o|n the ot|
|00004ea0| 68 65 72 20 74 68 72 65 | 65 2e 0a 58 0a 58 0a 58 |her thre|e..X.X.X|
|00004eb0| 2a 2a 2a 20 44 65 63 6f | 6d 70 72 65 73 73 69 6f |*** Deco|mpressio|
|00004ec0| 6e 20 6f 62 6a 65 63 74 | 20 73 74 72 75 63 74 75 |n object| structu|
|00004ed0| 72 65 20 2a 2a 2a 0a 58 | 0a 58 49 20 70 72 6f 70 |re ***.X|.XI prop|
|00004ee0| 6f 73 65 20 74 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |ose the |followin|
|00004ef0| 67 20 73 65 74 20 6f 66 | 20 6f 62 6a 65 63 74 73 |g set of| objects|
|00004f00| 20 66 6f 72 20 64 65 63 | 6f 6d 70 72 65 73 73 69 | for dec|ompressi|
|00004f10| 6f 6e 2e 20 20 54 68 65 | 20 67 65 6e 65 72 61 6c |on. The| general|
|00004f20| 0a 58 63 6f 6d 6d 65 6e | 74 73 20 61 74 20 74 68 |.Xcommen|ts at th|
|00004f30| 65 20 74 6f 70 20 6f 66 | 20 74 68 65 20 63 6f 6d |e top of| the com|
|00004f40| 70 72 65 73 73 69 6f 6e | 20 6f 62 6a 65 63 74 20 |pression| object |
|00004f50| 73 65 63 74 69 6f 6e 20 | 61 6c 73 6f 20 61 70 70 |section |also app|
|00004f60| 6c 79 20 68 65 72 65 2e | 0a 58 0a 58 31 2e 20 4a |ly here.|.X.X1. J|
|00004f70| 50 45 47 20 66 69 6c 65 | 20 73 63 61 6e 6e 69 6e |PEG file| scannin|
|00004f80| 67 2e 20 20 54 68 69 73 | 20 77 69 6c 6c 20 70 72 |g. This| will pr|
|00004f90| 6f 76 69 64 65 20 74 68 | 65 73 65 20 6d 65 74 68 |ovide th|ese meth|
|00004fa0| 6f 64 73 3a 0a 58 09 72 | 65 61 64 5f 66 69 6c 65 |ods:.X.r|ead_file|
|00004fb0| 5f 68 65 61 64 65 72 3a | 20 72 65 61 64 20 74 68 |_header:| read th|
|00004fc0| 65 20 66 69 6c 65 20 68 | 65 61 64 65 72 2c 20 64 |e file h|eader, d|
|00004fd0| 65 74 65 72 6d 69 6e 65 | 20 77 68 69 63 68 20 76 |etermine| which v|
|00004fe0| 61 72 69 61 6e 74 0a 58 | 09 09 09 20 20 4a 50 45 |ariant.X|... JPE|
|00004ff0| 47 20 66 6f 72 6d 61 74 | 20 69 73 20 69 6e 20 75 |G format| is in u|
|00005000| 73 65 2c 20 72 65 61 64 | 20 65 76 65 72 79 74 68 |se, read| everyth|
|00005010| 69 6e 67 20 74 68 72 6f | 75 67 68 20 53 4f 46 2e |ing thro|ugh SOF.|
|00005020| 0a 58 09 72 65 61 64 5f | 73 63 61 6e 5f 68 65 61 |.X.read_|scan_hea|
|00005030| 64 65 72 3a 20 72 65 61 | 64 20 73 63 61 6e 20 68 |der: rea|d scan h|
|00005040| 65 61 64 65 72 20 28 75 | 70 20 74 68 72 6f 75 67 |eader (u|p throug|
|00005050| 68 20 53 4f 53 29 2e 20 | 20 54 68 69 73 20 69 73 |h SOS). | This is|
|00005060| 20 63 61 6c 6c 65 64 0a | 58 09 09 09 20 20 61 66 | called.|X... af|
|00005070| 74 65 72 20 72 65 61 64 | 5f 66 69 6c 65 5f 68 65 |ter read|_file_he|
|00005080| 61 64 65 72 20 61 6e 64 | 20 61 67 61 69 6e 20 61 |ader and| again a|
|00005090| 66 74 65 72 20 65 61 63 | 68 20 73 63 61 6e 3b 0a |fter eac|h scan;.|
|000050a0| 58 09 09 09 20 20 69 74 | 20 72 65 74 75 72 6e 73 |X... it| returns|
|000050b0| 20 54 52 55 45 20 69 66 | 20 69 74 20 66 69 6e 64 | TRUE if| it find|
|000050c0| 73 20 53 4f 53 2c 20 46 | 41 4c 53 45 20 69 66 20 |s SOS, F|ALSE if |
|000050d0| 45 4f 49 2e 0a 58 09 72 | 65 61 64 5f 6a 70 65 67 |EOI..X.r|ead_jpeg|
|000050e0| 5f 64 61 74 61 3a 20 66 | 65 74 63 68 20 64 61 74 |_data: f|etch dat|
|000050f0| 61 20 66 6f 72 20 65 6e | 74 72 6f 70 79 20 64 65 |a for en|tropy de|
|00005100| 63 6f 64 65 72 2e 0a 58 | 09 72 65 73 79 6e 63 5f |coder..X|.resync_|
|00005110| 74 6f 5f 72 65 73 74 61 | 72 74 3a 20 74 72 79 20 |to_resta|rt: try |
|00005120| 74 6f 20 72 65 63 6f 76 | 65 72 20 66 72 6f 6d 20 |to recov|er from |
|00005130| 62 6f 67 75 73 20 64 61 | 74 61 20 28 73 65 65 20 |bogus da|ta (see |
|00005140| 62 65 6c 6f 77 29 2e 0a | 58 09 72 65 61 64 5f 73 |below)..|X.read_s|
|00005150| 63 61 6e 5f 74 72 61 69 | 6c 65 72 3a 20 66 69 6e |can_trai|ler: fin|
|00005160| 69 73 68 20 75 70 20 61 | 66 74 65 72 20 6f 6e 65 |ish up a|fter one|
|00005170| 20 73 63 61 6e 2c 20 70 | 72 65 70 61 72 65 20 66 | scan, p|repare f|
|00005180| 6f 72 20 61 6e 6f 74 68 | 65 72 20 63 61 6c 6c 0a |or anoth|er call.|
|00005190| 58 09 09 09 20 20 20 6f | 66 20 72 65 61 64 5f 73 |X... o|f read_s|
|000051a0| 63 61 6e 5f 68 65 61 64 | 65 72 20 28 6d 61 79 20 |can_head|er (may |
|000051b0| 62 65 20 61 20 6e 6f 2d | 6f 70 29 2e 0a 58 09 72 |be a no-|op)..X.r|
|000051c0| 65 61 64 5f 66 69 6c 65 | 5f 74 72 61 69 6c 65 72 |ead_file|_trailer|
|000051d0| 3a 20 66 69 6e 69 73 68 | 20 75 70 20 61 74 20 65 |: finish| up at e|
|000051e0| 6e 64 20 6f 66 20 66 69 | 6c 65 20 28 70 72 6f 62 |nd of fi|le (prob|
|000051f0| 61 62 6c 79 20 61 20 6e | 6f 2d 6f 70 29 2e 0a 58 |ably a n|o-op)..X|
|00005200| 20 20 20 54 68 65 20 65 | 6e 74 72 6f 70 79 20 64 | The e|ntropy d|
|00005210| 65 63 6f 64 65 72 20 6d | 75 73 74 20 64 65 61 6c |ecoder m|ust deal|
|00005220| 20 77 69 74 68 20 72 65 | 73 74 61 72 74 20 6d 61 | with re|start ma|
|00005230| 72 6b 65 72 73 2c 20 62 | 75 74 20 61 6c 6c 20 6f |rkers, b|ut all o|
|00005240| 74 68 65 72 20 4a 50 45 | 47 0a 58 20 20 20 6d 61 |ther JPE|G.X ma|
|00005250| 72 6b 65 72 20 74 79 70 | 65 73 20 77 69 6c 6c 20 |rker typ|es will |
|00005260| 62 65 20 68 61 6e 64 6c | 65 64 20 69 6e 20 74 68 |be handl|ed in th|
|00005270| 69 73 20 6f 62 6a 65 63 | 74 3b 20 75 73 65 66 75 |is objec|t; usefu|
|00005280| 6c 20 64 61 74 61 20 66 | 72 6f 6d 20 74 68 65 20 |l data f|rom the |
|00005290| 6d 61 72 6b 65 72 73 0a | 58 20 20 20 77 69 6c 6c |markers.|X will|
|000052a0| 20 62 65 20 65 78 74 72 | 61 63 74 65 64 20 69 6e | be extr|acted in|
|000052b0| 74 6f 20 64 61 74 61 20 | 73 74 72 75 63 74 75 72 |to data |structur|
|000052c0| 65 73 20 61 76 61 69 6c | 61 62 6c 65 20 74 6f 20 |es avail|able to |
|000052d0| 73 75 62 73 65 71 75 65 | 6e 74 20 72 6f 75 74 69 |subseque|nt routi|
|000052e0| 6e 65 73 2e 0a 58 20 20 | 20 4e 6f 74 65 20 74 68 |nes..X | Note th|
|000052f0| 61 74 20 6f 6e 20 65 78 | 69 74 20 66 72 6f 6d 20 |at on ex|it from |
|00005300| 72 65 61 64 5f 66 69 6c | 65 5f 68 65 61 64 65 72 |read_fil|e_header|
|00005310| 2c 20 6f 6e 6c 79 20 74 | 68 65 20 53 4f 46 2d 6d |, only t|he SOF-m|
|00005320| 61 72 6b 65 72 20 64 61 | 74 61 20 73 68 6f 75 6c |arker da|ta shoul|
|00005330| 64 20 62 65 0a 58 20 20 | 20 61 73 73 75 6d 65 64 |d be.X | assumed|
|00005340| 20 76 61 6c 69 64 20 28 | 69 6d 61 67 65 20 73 69 | valid (|image si|
|00005350| 7a 65 2c 20 63 6f 6d 70 | 6f 6e 65 6e 74 20 49 44 |ze, comp|onent ID|
|00005360| 73 2c 20 73 61 6d 70 6c | 69 6e 67 20 66 61 63 74 |s, sampl|ing fact|
|00005370| 6f 72 73 29 3b 20 6f 74 | 68 65 72 20 64 61 74 61 |ors); ot|her data|
|00005380| 0a 58 20 20 20 73 75 63 | 68 20 61 73 20 48 75 66 |.X suc|h as Huf|
|00005390| 66 6d 61 6e 20 74 61 62 | 6c 65 73 20 6d 61 79 20 |fman tab|les may |
|000053a0| 6e 6f 74 20 61 70 70 65 | 61 72 20 75 6e 74 69 6c |not appe|ar until|
|000053b0| 20 61 66 74 65 72 20 74 | 68 65 20 53 4f 46 2e 20 | after t|he SOF. |
|000053c0| 20 54 68 65 20 6f 76 65 | 72 61 6c 6c 0a 58 20 20 | The ove|rall.X |
|000053d0| 20 69 6d 61 67 65 20 73 | 69 7a 65 20 61 6e 64 20 | image s|ize and |
|000053e0| 63 6f 6c 6f 72 73 70 61 | 63 65 20 63 61 6e 20 62 |colorspa|ce can b|
|000053f0| 65 20 64 65 74 65 72 6d | 69 6e 65 64 20 61 66 74 |e determ|ined aft|
|00005400| 65 72 20 72 65 61 64 5f | 66 69 6c 65 5f 68 65 61 |er read_|file_hea|
|00005410| 64 65 72 2c 20 62 75 74 | 20 6e 6f 74 0a 58 20 20 |der, but| not.X |
|00005420| 20 77 68 65 74 68 65 72 | 20 6f 72 20 68 6f 77 20 | whether| or how |
|00005430| 74 68 65 20 64 61 74 61 | 20 69 73 20 69 6e 74 65 |the data| is inte|
|00005440| 72 6c 65 61 76 65 64 2e | 20 20 28 54 68 69 73 20 |rleaved.| (This |
|00005450| 68 69 64 65 73 20 77 68 | 69 63 68 20 76 61 72 69 |hides wh|ich vari|
|00005460| 61 6e 74 20 4a 50 45 47 | 0a 58 20 20 20 66 69 6c |ant JPEG|.X fil|
|00005470| 65 20 66 6f 72 6d 61 74 | 20 69 73 20 62 65 69 6e |e format| is bein|
|00005480| 67 20 72 65 61 64 2e 20 | 20 49 6e 20 70 61 72 74 |g read. | In part|
|00005490| 69 63 75 6c 61 72 2c 20 | 66 6f 72 20 4a 50 45 47 |icular, |for JPEG|
|000054a0| 2d 69 6e 2d 54 49 46 46 | 20 74 68 65 20 72 65 61 |-in-TIFF| the rea|
|000054b0| 64 5f 68 65 61 64 65 72 | 0a 58 20 20 20 72 6f 75 |d_header|.X rou|
|000054c0| 74 69 6e 65 73 20 6d 69 | 67 68 74 20 6e 6f 74 20 |tines mi|ght not |
|000054d0| 62 65 20 73 63 61 6e 6e | 69 6e 67 20 73 74 61 6e |be scann|ing stan|
|000054e0| 64 61 72 64 20 4a 50 45 | 47 20 6d 61 72 6b 65 72 |dard JPE|G marker|
|000054f0| 73 20 61 74 20 61 6c 6c | 3b 20 74 68 65 79 20 63 |s at all|; they c|
|00005500| 6f 75 6c 64 0a 58 20 20 | 20 65 78 74 72 61 63 74 |ould.X | extract|
|00005510| 20 74 68 65 20 64 61 74 | 61 20 66 72 6f 6d 20 54 | the dat|a from T|
|00005520| 49 46 46 20 74 61 67 73 | 2e 20 20 54 68 65 20 75 |IFF tags|. The u|
|00005530| 73 65 72 20 69 6e 74 65 | 72 66 61 63 65 20 77 69 |ser inte|rface wi|
|00005540| 6c 6c 20 61 6c 72 65 61 | 64 79 20 68 61 76 65 0a |ll alrea|dy have.|
|00005550| 58 20 20 20 6f 70 65 6e | 65 64 20 74 68 65 20 69 |X open|ed the i|
|00005560| 6e 70 75 74 20 66 69 6c | 65 20 61 6e 64 20 70 6f |nput fil|e and po|
|00005570| 73 73 69 62 6c 79 20 72 | 65 61 64 20 70 61 72 74 |ssibly r|ead part|
|00005580| 20 6f 66 20 74 68 65 20 | 68 65 61 64 65 72 20 62 | of the |header b|
|00005590| 65 66 6f 72 65 0a 58 20 | 20 20 72 65 61 64 5f 66 |efore.X | read_f|
|000055a0| 69 6c 65 5f 68 65 61 64 | 65 72 20 69 73 20 63 61 |ile_head|er is ca|
|000055b0| 6c 6c 65 64 2e 29 0a 58 | 0a 58 20 20 20 57 68 65 |lled.).X|.X Whe|
|000055c0| 6e 20 72 65 61 64 69 6e | 67 20 61 20 66 69 6c 65 |n readin|g a file|
|000055d0| 20 77 69 74 68 20 61 20 | 6e 6f 6e 7a 65 72 6f 20 | with a |nonzero |
|000055e0| 72 65 73 74 61 72 74 20 | 69 6e 74 65 72 76 61 6c |restart |interval|
|000055f0| 2c 20 74 68 65 20 65 6e | 74 72 6f 70 79 20 64 65 |, the en|tropy de|
|00005600| 63 6f 64 65 72 0a 58 20 | 20 20 65 78 70 65 63 74 |coder.X | expect|
|00005610| 73 20 74 6f 20 73 65 65 | 20 61 20 63 6f 72 72 65 |s to see| a corre|
|00005620| 63 74 20 73 65 71 75 65 | 6e 63 65 20 6f 66 20 72 |ct seque|nce of r|
|00005630| 65 73 74 61 72 74 20 6d | 61 72 6b 65 72 73 2e 20 |estart m|arkers. |
|00005640| 20 49 6e 20 73 6f 6d 65 | 20 63 61 73 65 73 2c 20 | In some| cases, |
|00005650| 74 68 65 73 65 0a 58 20 | 20 20 6d 61 72 6b 65 72 |these.X | marker|
|00005660| 73 20 6d 61 79 20 62 65 | 20 73 79 6e 74 68 65 73 |s may be| synthes|
|00005670| 69 7a 65 64 20 62 79 20 | 74 68 65 20 66 69 6c 65 |ized by |the file|
|00005680| 2d 66 6f 72 6d 61 74 20 | 6d 6f 64 75 6c 65 20 28 |-format |module (|
|00005690| 61 20 54 49 46 46 20 72 | 65 61 64 65 72 20 6d 69 |a TIFF r|eader mi|
|000056a0| 67 68 74 0a 58 20 20 20 | 64 6f 20 73 6f 2c 20 66 |ght.X |do so, f|
|000056b0| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 75 73 69 6e |or examp|le, usin|
|000056c0| 67 20 74 69 6c 65 20 62 | 6f 75 6e 64 61 72 79 20 |g tile b|oundary |
|000056d0| 70 6f 69 6e 74 65 72 73 | 20 74 6f 20 64 65 74 65 |pointers| to dete|
|000056e0| 72 6d 69 6e 65 20 77 68 | 65 72 65 20 74 68 65 0a |rmine wh|ere the.|
|000056f0| 58 20 20 20 72 65 73 74 | 61 72 74 20 69 6e 74 65 |X rest|art inte|
|00005700| 72 76 61 6c 73 20 66 61 | 6c 6c 29 2e 20 20 49 66 |rvals fa|ll). If|
|00005710| 20 74 68 65 20 69 6e 63 | 6f 6d 69 6e 67 20 64 61 | the inc|oming da|
|00005720| 74 61 20 69 73 20 63 6f | 72 72 75 70 74 65 64 2c |ta is co|rrupted,|
|00005730| 20 74 68 65 20 65 6e 74 | 72 6f 70 79 0a 58 20 20 | the ent|ropy.X |
|00005740| 20 64 65 63 6f 64 65 72 | 20 77 69 6c 6c 20 72 65 | decoder| will re|
|00005750| 61 64 20 61 73 20 66 61 | 72 20 61 73 20 74 68 65 |ad as fa|r as the|
|00005760| 20 6e 65 78 74 20 4a 50 | 45 47 20 6d 61 72 6b 65 | next JP|EG marke|
|00005770| 72 2c 20 77 68 69 63 68 | 20 6d 61 79 20 6f 72 20 |r, which| may or |
|00005780| 6d 61 79 20 6e 6f 74 20 | 62 65 0a 58 20 20 20 74 |may not |be.X t|
|00005790| 68 65 20 65 78 70 65 63 | 74 65 64 20 6e 65 78 74 |he expec|ted next|
|000057a0| 20 72 65 73 74 61 72 74 | 20 6d 61 72 6b 65 72 2e | restart| marker.|
|000057b0| 20 20 49 66 20 69 74 20 | 69 73 6e 27 74 2c 20 72 | If it |isn't, r|
|000057c0| 65 73 79 6e 63 5f 74 6f | 5f 72 65 73 74 61 72 74 |esync_to|_restart|
|000057d0| 20 69 73 20 63 61 6c 6c | 65 64 0a 58 20 20 20 74 | is call|ed.X t|
|000057e0| 6f 20 74 72 79 20 74 6f | 20 6c 6f 63 61 74 65 20 |o try to| locate |
|000057f0| 61 20 67 6f 6f 64 20 70 | 6c 61 63 65 20 74 6f 20 |a good p|lace to |
|00005800| 72 65 73 75 6d 65 20 72 | 65 61 64 69 6e 67 2e 20 |resume r|eading. |
|00005810| 20 57 65 20 6d 61 6b 65 | 20 74 68 69 73 20 68 65 | We make| this he|
|00005820| 75 72 69 73 74 69 63 20 | 61 0a 58 20 20 20 66 69 |uristic |a.X fi|
|00005830| 6c 65 2d 66 6f 72 6d 61 | 74 2d 64 65 70 65 6e 64 |le-forma|t-depend|
|00005840| 65 6e 74 20 6f 70 65 72 | 61 74 69 6f 6e 20 73 69 |ent oper|ation si|
|00005850| 6e 63 65 20 73 6f 6d 65 | 20 66 69 6c 65 20 66 6f |nce some| file fo|
|00005860| 72 6d 61 74 73 20 6d 61 | 79 20 68 61 76 65 20 73 |rmats ma|y have s|
|00005870| 70 65 63 69 61 6c 0a 58 | 20 20 20 69 6e 66 6f 20 |pecial.X| info |
|00005880| 74 68 61 74 27 73 20 6e | 6f 74 20 61 76 61 69 6c |that's n|ot avail|
|00005890| 61 62 6c 65 20 74 6f 20 | 74 68 65 20 65 6e 74 72 |able to |the entr|
|000058a0| 6f 70 79 20 64 65 63 6f | 64 65 72 20 28 61 67 61 |opy deco|der (aga|
|000058b0| 69 6e 2c 20 54 49 46 46 | 20 69 73 20 61 6e 0a 58 |in, TIFF| is an.X|
|000058c0| 20 20 20 65 78 61 6d 70 | 6c 65 29 2e 20 20 4e 6f | examp|le). No|
|000058d0| 74 65 20 74 68 61 74 20 | 72 65 73 79 6e 63 5f 74 |te that |resync_t|
|000058e0| 6f 5f 72 65 73 74 61 72 | 74 20 69 73 20 4e 4f 54 |o_restar|t is NOT|
|000058f0| 20 63 61 6c 6c 65 64 20 | 61 74 20 74 68 65 20 65 | called |at the e|
|00005900| 6e 64 20 6f 66 20 61 20 | 73 63 61 6e 3b 0a 58 20 |nd of a |scan;.X |
|00005910| 20 20 69 74 20 69 73 20 | 72 65 61 64 5f 73 63 61 | it is |read_sca|
|00005920| 6e 5f 74 72 61 69 6c 65 | 72 27 73 20 72 65 73 70 |n_traile|r's resp|
|00005930| 6f 6e 73 69 62 69 6c 69 | 74 79 20 74 6f 20 72 65 |onsibili|ty to re|
|00005940| 73 79 6e 63 20 74 68 65 | 72 65 2e 0a 58 0a 58 20 |sync the|re..X.X |
|00005950| 20 20 4e 4f 54 45 3a 20 | 66 6f 72 20 4a 46 49 46 | NOTE: |for JFIF|
|00005960| 2f 72 61 77 2d 4a 50 45 | 47 20 66 69 6c 65 20 66 |/raw-JPE|G file f|
|00005970| 6f 72 6d 61 74 2c 20 74 | 68 65 20 72 65 61 64 5f |ormat, t|he read_|
|00005980| 6a 70 65 67 5f 64 61 74 | 61 20 72 6f 75 74 69 6e |jpeg_dat|a routin|
|00005990| 65 20 69 73 20 61 63 74 | 75 61 6c 6c 79 0a 58 20 |e is act|ually.X |
|000059a0| 20 20 73 75 70 70 6c 69 | 65 64 20 62 79 20 74 68 | suppli|ed by th|
|000059b0| 65 20 75 73 65 72 20 69 | 6e 74 65 72 66 61 63 65 |e user i|nterface|
|000059c0| 3b 20 74 68 65 20 6a 72 | 64 6a 66 69 66 20 6d 6f |; the jr|djfif mo|
|000059d0| 64 75 6c 65 20 75 73 65 | 73 20 72 65 61 64 5f 6a |dule use|s read_j|
|000059e0| 70 65 67 5f 64 61 74 61 | 0a 58 20 20 20 69 6e 74 |peg_data|.X int|
|000059f0| 65 72 6e 61 6c 6c 79 20 | 74 6f 20 73 63 61 6e 20 |ernally |to scan |
|00005a00| 74 68 65 20 69 6e 70 75 | 74 20 73 74 72 65 61 6d |the inpu|t stream|
|00005a10| 2e 20 20 54 68 69 73 20 | 6d 61 6b 65 73 20 69 74 |. This |makes it|
|00005a20| 20 70 6f 73 73 69 62 6c | 65 20 66 6f 72 20 74 68 | possibl|e for th|
|00005a30| 65 20 75 73 65 72 0a 58 | 20 20 20 69 6e 74 65 72 |e user.X| inter|
|00005a40| 66 61 63 65 20 6d 6f 64 | 75 6c 65 20 74 6f 20 73 |face mod|ule to s|
|00005a50| 69 6e 67 6c 65 2d 68 61 | 6e 64 65 64 6c 79 20 69 |ingle-ha|ndedly i|
|00005a60| 6d 70 6c 65 6d 65 6e 74 | 20 73 70 65 63 69 61 6c |mplement| special|
|00005a70| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 73 20 6c 69 | applica|tions li|
|00005a80| 6b 65 0a 58 20 20 20 72 | 65 61 64 69 6e 67 20 66 |ke.X r|eading f|
|00005a90| 72 6f 6d 20 61 20 6e 6f | 6e 2d 73 74 64 69 6f 20 |rom a no|n-stdio |
|00005aa0| 73 6f 75 72 63 65 2e 20 | 20 46 6f 72 20 4a 50 45 |source. | For JPE|
|00005ab0| 47 2d 69 6e 2d 54 49 46 | 46 20 66 6f 72 6d 61 74 |G-in-TIF|F format|
|00005ac0| 2c 20 74 68 65 20 6e 65 | 65 64 20 66 6f 72 0a 58 |, the ne|ed for.X|
|00005ad0| 20 20 20 72 61 6e 64 6f | 6d 20 61 63 63 65 73 73 | rando|m access|
|00005ae0| 20 77 69 6c 6c 20 6d 61 | 6b 65 20 69 74 20 69 6d | will ma|ke it im|
|00005af0| 70 6f 73 73 69 62 6c 65 | 20 66 6f 72 20 74 68 69 |possible| for thi|
|00005b00| 73 20 74 6f 20 77 6f 72 | 6b 3b 20 68 65 6e 63 65 |s to wor|k; hence|
|00005b10| 20 74 68 65 20 54 49 46 | 46 0a 58 20 20 20 68 65 | the TIF|F.X he|
|00005b20| 61 64 65 72 20 6d 6f 64 | 75 6c 65 20 77 69 6c 6c |ader mod|ule will|
|00005b30| 20 6f 76 65 72 72 69 64 | 65 20 74 68 65 20 55 49 | overrid|e the UI|
|00005b40| 2d 73 75 70 70 6c 69 65 | 64 20 72 65 61 64 5f 6a |-supplie|d read_j|
|00005b50| 70 65 67 5f 64 61 74 61 | 20 72 6f 75 74 69 6e 65 |peg_data| routine|
|00005b60| 2e 0a 58 20 20 20 4e 6f | 6e 2d 73 74 64 69 6f 20 |..X No|n-stdio |
|00005b70| 69 6e 70 75 74 20 66 72 | 6f 6d 20 61 20 54 49 46 |input fr|om a TIF|
|00005b80| 46 20 66 69 6c 65 20 77 | 69 6c 6c 20 72 65 71 75 |F file w|ill requ|
|00005b90| 69 72 65 20 65 78 74 65 | 6e 73 69 76 65 20 73 75 |ire exte|nsive su|
|00005ba0| 72 67 65 72 79 20 74 6f | 20 74 68 65 20 54 49 46 |rgery to| the TIF|
|00005bb0| 46 0a 58 20 20 20 68 65 | 61 64 65 72 20 6d 6f 64 |F.X he|ader mod|
|00005bc0| 75 6c 65 2c 20 69 66 20 | 69 6e 64 65 65 64 20 69 |ule, if |indeed i|
|00005bd0| 74 20 69 73 20 70 72 61 | 63 74 69 63 61 6c 20 61 |t is pra|ctical a|
|00005be0| 74 20 61 6c 6c 2e 0a 58 | 0a 58 32 2e 20 45 6e 74 |t all..X|.X2. Ent|
|00005bf0| 72 6f 70 79 20 28 48 75 | 66 66 6d 61 6e 20 6f 72 |ropy (Hu|ffman or|
|00005c00| 20 61 72 69 74 68 6d 65 | 74 69 63 29 20 64 65 63 | arithme|tic) dec|
|00005c10| 6f 64 69 6e 67 20 6f 66 | 20 74 68 65 20 63 6f 65 |oding of| the coe|
|00005c20| 66 66 69 63 69 65 6e 74 | 20 73 65 71 75 65 6e 63 |fficient| sequenc|
|00005c30| 65 2e 0a 58 09 65 6e 74 | 72 6f 70 79 5f 64 65 63 |e..X.ent|ropy_dec|
|00005c40| 6f 64 65 5f 69 6e 69 74 | 3a 20 70 72 65 70 61 72 |ode_init|: prepar|
|00005c50| 65 20 66 6f 72 20 6f 6e | 65 20 73 63 61 6e 2e 0a |e for on|e scan..|
|00005c60| 58 09 65 6e 74 72 6f 70 | 79 5f 64 65 63 6f 64 65 |X.entrop|y_decode|
|00005c70| 3a 20 64 65 63 6f 64 65 | 73 20 61 6e 64 20 72 65 |: decode|s and re|
|00005c80| 74 75 72 6e 73 20 61 6e | 20 4d 43 55 27 73 20 77 |turns an| MCU's w|
|00005c90| 6f 72 74 68 20 6f 66 20 | 71 75 61 6e 74 69 7a 65 |orth of |quantize|
|00005ca0| 64 0a 58 09 09 09 63 6f | 65 66 66 69 63 69 65 6e |d.X...co|efficien|
|00005cb0| 74 73 20 70 65 72 20 63 | 61 6c 6c 2e 0a 58 09 65 |ts per c|all..X.e|
|00005cc0| 6e 74 72 6f 70 79 5f 64 | 65 63 6f 64 65 5f 74 65 |ntropy_d|ecode_te|
|00005cd0| 72 6d 3a 20 66 69 6e 69 | 73 68 20 75 70 20 61 66 |rm: fini|sh up af|
|00005ce0| 74 65 72 20 61 20 73 63 | 61 6e 20 28 6d 61 79 20 |ter a sc|an (may |
|00005cf0| 62 65 20 61 20 6e 6f 2d | 6f 70 29 2e 0a 58 20 20 |be a no-|op)..X |
|00005d00| 20 54 68 69 73 20 77 69 | 6c 6c 20 72 65 61 64 20 | This wi|ll read |
|00005d10| 72 61 77 20 64 61 74 61 | 20 62 79 20 63 61 6c 6c |raw data| by call|
|00005d20| 69 6e 67 20 74 68 65 20 | 72 65 61 64 5f 6a 70 65 |ing the |read_jpe|
|00005d30| 67 5f 64 61 74 61 20 6d | 65 74 68 6f 64 20 28 49 |g_data m|ethod (I|
|00005d40| 20 64 6f 6e 27 74 20 73 | 65 65 0a 58 20 20 20 61 | don't s|ee.X a|
|00005d50| 6e 79 20 72 65 61 73 6f | 6e 20 74 6f 20 70 72 6f |ny reaso|n to pro|
|00005d60| 76 69 64 65 20 61 20 66 | 75 72 74 68 65 72 20 6c |vide a f|urther l|
|00005d70| 65 76 65 6c 20 6f 66 20 | 69 6e 64 69 72 65 63 74 |evel of |indirect|
|00005d80| 69 6f 6e 29 2e 0a 58 20 | 20 20 28 54 68 69 73 20 |ion)..X | (This |
|00005d90| 68 69 64 65 73 20 77 68 | 69 63 68 20 65 6e 74 72 |hides wh|ich entr|
|00005da0| 6f 70 79 20 65 6e 63 6f | 64 69 6e 67 20 6d 65 74 |opy enco|ding met|
|00005db0| 68 6f 64 20 69 73 20 69 | 6e 20 75 73 65 2e 29 0a |hod is i|n use.).|
|00005dc0| 58 0a 58 33 2e 20 51 75 | 61 6e 74 69 7a 61 74 69 |X.X3. Qu|antizati|
|00005dd0| 6f 6e 20 64 65 73 63 61 | 6c 69 6e 67 20 61 6e 64 |on desca|ling and|
|00005de0| 20 7a 69 67 7a 61 67 20 | 72 65 6f 72 64 65 72 69 | zigzag |reorderi|
|00005df0| 6e 67 20 6f 66 20 74 68 | 65 20 65 6c 65 6d 65 6e |ng of th|e elemen|
|00005e00| 74 73 20 69 6e 20 65 61 | 63 68 20 38 78 38 0a 58 |ts in ea|ch 8x8.X|
|00005e10| 20 20 20 62 6c 6f 63 6b | 2e 20 20 54 68 69 73 20 | block|. This |
|00005e20| 77 69 6c 6c 20 62 65 20 | 66 6f 6c 64 65 64 20 69 |will be |folded i|
|00005e30| 6e 74 6f 20 65 6e 74 72 | 6f 70 79 5f 64 65 63 6f |nto entr|opy_deco|
|00005e40| 64 65 20 66 6f 72 20 65 | 66 66 69 63 69 65 6e 63 |de for e|fficienc|
|00005e50| 79 20 72 65 61 73 6f 6e | 73 3a 0a 58 20 20 20 6d |y reason|s:.X m|
|00005e60| 61 6e 79 20 6f 66 20 74 | 68 65 20 63 6f 65 66 66 |any of t|he coeff|
|00005e70| 69 63 69 65 6e 74 73 20 | 61 72 65 20 7a 65 72 6f |icients |are zero|
|00005e80| 65 73 2c 20 61 6e 64 20 | 74 68 69 73 20 63 61 6e |es, and |this can|
|00005e90| 20 62 65 20 65 78 70 6c | 6f 69 74 65 64 20 6d 6f | be expl|oited mo|
|00005ea0| 73 74 20 65 61 73 69 6c | 79 0a 58 20 20 20 77 69 |st easil|y.X wi|
|00005eb0| 74 68 69 6e 20 65 6e 74 | 72 6f 70 79 5f 64 65 63 |thin ent|ropy_dec|
|00005ec0| 6f 64 65 20 73 69 6e 63 | 65 20 74 68 65 20 65 6e |ode sinc|e the en|
|00005ed0| 63 6f 64 69 6e 67 20 65 | 78 70 6c 69 63 69 74 6c |coding e|xplicitl|
|00005ee0| 79 20 73 6b 69 70 73 20 | 7a 65 72 6f 65 73 2e 0a |y skips |zeroes..|
|00005ef0| 58 0a 58 34 2e 20 4d 43 | 55 20 64 69 73 61 73 73 |X.X4. MC|U disass|
|00005f00| 65 6d 62 6c 79 20 28 63 | 6f 6e 76 65 72 73 69 6f |embly (c|onversio|
|00005f10| 6e 20 6f 66 20 61 20 70 | 6f 73 73 69 62 6c 79 20 |n of a p|ossibly |
|00005f20| 69 6e 74 65 72 6c 65 61 | 76 65 64 20 73 65 71 75 |interlea|ved sequ|
|00005f30| 65 6e 63 65 20 6f 66 20 | 38 78 38 0a 58 20 20 20 |ence of |8x8.X |
|00005f40| 62 6c 6f 63 6b 73 20 62 | 61 63 6b 20 74 6f 20 73 |blocks b|ack to s|
|00005f50| 65 70 61 72 61 74 65 20 | 63 6f 6d 70 6f 6e 65 6e |eparate |componen|
|00005f60| 74 73 20 69 6e 20 70 69 | 78 65 6c 20 6d 61 70 20 |ts in pi|xel map |
|00005f70| 6f 72 64 65 72 29 2e 0a | 58 09 64 69 73 61 73 73 |order)..|X.disass|
|00005f80| 65 6d 62 6c 65 5f 69 6e | 69 74 3a 20 69 6e 69 74 |emble_in|it: init|
|00005f90| 69 61 6c 69 7a 65 2e 20 | 20 54 68 69 73 20 77 69 |ialize. | This wi|
|00005fa0| 6c 6c 20 62 65 20 63 61 | 6c 6c 65 64 20 6f 6e 63 |ll be ca|lled onc|
|00005fb0| 65 20 70 65 72 20 73 63 | 61 6e 2e 0a 58 09 64 69 |e per sc|an..X.di|
|00005fc0| 73 61 73 73 65 6d 62 6c | 65 5f 4d 43 55 3a 20 20 |sassembl|e_MCU: |
|00005fd0| 47 69 76 65 6e 20 61 6e | 20 4d 43 55 27 73 20 77 |Given an| MCU's w|
|00005fe0| 6f 72 74 68 20 6f 66 20 | 64 65 71 75 61 6e 74 69 |orth of |dequanti|
|00005ff0| 7a 65 64 20 62 6c 6f 63 | 6b 73 2c 0a 58 09 09 09 |zed bloc|ks,.X...|
|00006000| 20 20 64 69 73 74 72 69 | 62 75 74 65 20 74 68 65 | distri|bute the|
|00006010| 6d 20 69 6e 74 6f 20 74 | 68 65 20 70 72 6f 70 65 |m into t|he prope|
|00006020| 72 20 6c 6f 63 61 74 69 | 6f 6e 73 20 69 6e 20 61 |r locati|ons in a|
|00006030| 0a 58 09 09 09 20 20 63 | 6f 65 66 66 69 63 69 65 |.X... c|oefficie|
|00006040| 6e 74 20 69 6d 61 67 65 | 20 61 72 72 61 79 2e 0a |nt image| array..|
|00006050| 58 09 64 69 73 61 73 73 | 65 6d 62 6c 65 5f 74 65 |X.disass|emble_te|
|00006060| 72 6d 3a 20 63 6c 65 61 | 6e 20 75 70 20 61 74 20 |rm: clea|n up at |
|00006070| 74 68 65 20 65 6e 64 20 | 6f 66 20 61 20 73 63 61 |the end |of a sca|
|00006080| 6e 2e 0a 58 20 20 20 50 | 72 6f 62 61 62 6c 79 20 |n..X P|robably |
|00006090| 74 68 69 73 20 73 68 6f | 75 6c 64 20 62 65 20 63 |this sho|uld be c|
|000060a0| 61 6c 6c 65 64 20 6f 6e | 63 65 20 70 65 72 20 4d |alled on|ce per M|
|000060b0| 43 55 20 72 6f 77 20 61 | 6e 64 20 73 68 6f 75 6c |CU row a|nd shoul|
|000060c0| 64 20 63 61 6c 6c 20 74 | 68 65 0a 58 20 20 20 65 |d call t|he.X e|
|000060d0| 6e 74 72 6f 70 79 20 64 | 65 63 6f 64 65 72 20 72 |ntropy d|ecoder r|
|000060e0| 65 70 65 61 74 65 64 6c | 79 20 74 6f 20 6f 62 74 |epeatedl|y to obt|
|000060f0| 61 69 6e 20 74 68 65 20 | 72 6f 77 27 73 20 64 61 |ain the |row's da|
|00006100| 74 61 2e 20 20 54 68 65 | 20 6f 75 74 70 75 74 20 |ta. The| output |
|00006110| 69 73 0a 58 20 20 20 61 | 6c 77 61 79 73 20 61 20 |is.X a|lways a |
|00006120| 6d 75 6c 74 69 70 6c 65 | 20 6f 66 20 61 6e 20 4d |multiple| of an M|
|00006130| 43 55 27 73 20 64 69 6d | 65 6e 73 69 6f 6e 73 2e |CU's dim|ensions.|
|00006140| 0a 58 20 20 20 28 41 6e | 20 6f 62 6a 65 63 74 20 |.X (An| object |
|00006150| 6f 6e 20 74 68 65 20 67 | 72 6f 75 6e 64 73 20 74 |on the g|rounds t|
|00006160| 68 61 74 20 6d 75 6c 74 | 69 70 6c 65 20 69 6e 73 |hat mult|iple ins|
|00006170| 74 61 6e 74 69 61 74 69 | 6f 6e 73 20 6d 69 67 68 |tantiati|ons migh|
|00006180| 74 20 62 65 20 75 73 65 | 66 75 6c 2e 29 0a 58 0a |t be use|ful.).X.|
|00006190| 58 35 2e 20 43 72 6f 73 | 73 2d 62 6c 6f 63 6b 20 |X5. Cros|s-block |
|000061a0| 73 6d 6f 6f 74 68 69 6e | 67 20 70 65 72 20 4a 50 |smoothin|g per JP|
|000061b0| 45 47 20 73 65 63 74 69 | 6f 6e 20 4b 2e 38 20 6f |EG secti|on K.8 o|
|000061c0| 72 20 61 20 73 69 6d 69 | 6c 61 72 20 61 6c 67 6f |r a simi|lar algo|
|000061d0| 72 69 74 68 6d 2e 0a 58 | 09 73 6d 6f 6f 74 68 5f |rithm..X|.smooth_|
|000061e0| 63 6f 65 66 66 69 63 69 | 65 6e 74 73 3a 20 47 69 |coeffici|ents: Gi|
|000061f0| 76 65 6e 20 74 68 72 65 | 65 20 62 6c 6f 63 6b 20 |ven thre|e block |
|00006200| 72 6f 77 73 27 20 77 6f | 72 74 68 20 6f 66 20 61 |rows' wo|rth of a|
|00006210| 20 73 69 6e 67 6c 65 0a | 58 09 09 09 20 20 20 20 | single.|X... |
|00006220| 20 63 6f 6d 70 6f 6e 65 | 6e 74 2c 20 65 6d 69 74 | compone|nt, emit|
|00006230| 20 61 20 73 6d 6f 6f 74 | 68 65 64 20 65 71 75 69 | a smoot|hed equi|
|00006240| 76 61 6c 65 6e 74 20 6f | 66 20 74 68 65 0a 58 09 |valent o|f the.X.|
|00006250| 09 09 20 20 20 20 20 6d | 69 64 64 6c 65 20 72 6f |.. m|iddle ro|
|00006260| 77 2e 20 20 54 68 65 20 | 22 61 62 6f 76 65 22 20 |w. The |"above" |
|00006270| 61 6e 64 20 22 62 65 6c | 6f 77 22 20 70 6f 69 6e |and "bel|ow" poin|
|00006280| 74 65 72 73 0a 58 09 09 | 09 20 20 20 20 20 6d 61 |ters.X..|. ma|
|00006290| 79 20 62 65 20 4e 55 4c | 4c 20 69 66 20 61 74 20 |y be NUL|L if at |
|000062a0| 74 6f 70 2f 62 6f 74 74 | 6f 6d 20 6f 66 20 69 6d |top/bott|om of im|
|000062b0| 61 67 65 2e 0a 58 20 20 | 20 54 68 65 20 70 69 70 |age..X | The pip|
|000062c0| 65 6c 69 6e 65 20 63 6f | 6e 74 72 6f 6c 6c 65 72 |eline co|ntroller|
|000062d0| 20 77 69 6c 6c 20 64 6f | 20 74 68 65 20 6e 65 63 | will do| the nec|
|000062e0| 65 73 73 61 72 79 20 62 | 75 66 66 65 72 69 6e 67 |essary b|uffering|
|000062f0| 20 74 6f 20 70 72 6f 76 | 69 64 65 20 74 68 65 0a | to prov|ide the.|
|00006300| 58 20 20 20 61 62 6f 76 | 65 2f 62 65 6c 6f 77 20 |X abov|e/below |
|00006310| 63 6f 6e 74 65 78 74 2e | 20 20 53 6d 6f 6f 74 68 |context.| Smooth|
|00006320| 69 6e 67 20 77 69 6c 6c | 20 62 65 20 6f 70 74 69 |ing will| be opti|
|00006330| 6f 6e 61 6c 20 73 69 6e | 63 65 20 61 20 67 6f 6f |onal sin|ce a goo|
|00006340| 64 20 64 65 61 6c 20 6f | 66 0a 58 20 20 20 65 78 |d deal o|f.X ex|
|00006350| 74 72 61 20 6d 65 6d 6f | 72 79 20 69 73 20 6e 65 |tra memo|ry is ne|
|00006360| 65 64 65 64 20 74 6f 20 | 62 75 66 66 65 72 20 74 |eded to |buffer t|
|00006370| 68 65 20 61 64 64 69 74 | 69 6f 6e 61 6c 20 62 6c |he addit|ional bl|
|00006380| 6f 63 6b 20 72 6f 77 73 | 2e 0a 58 20 20 20 28 54 |ock rows|..X (T|
|00006390| 68 69 73 20 6f 62 6a 65 | 63 74 20 68 69 64 65 73 |his obje|ct hides|
|000063a0| 20 74 68 65 20 64 65 74 | 61 69 6c 73 20 6f 66 20 | the det|ails of |
|000063b0| 74 68 65 20 73 6d 6f 6f | 74 68 69 6e 67 20 61 6c |the smoo|thing al|
|000063c0| 67 6f 72 69 74 68 6d 2e | 29 0a 58 0a 58 36 2e 20 |gorithm.|).X.X6. |
|000063d0| 49 6e 76 65 72 73 65 20 | 44 43 54 20 74 72 61 6e |Inverse |DCT tran|
|000063e0| 73 66 6f 72 6d 61 74 69 | 6f 6e 20 6f 66 20 65 61 |sformati|on of ea|
|000063f0| 63 68 20 38 78 38 20 62 | 6c 6f 63 6b 2e 0a 58 09 |ch 8x8 b|lock..X.|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.