home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume34 / jpeg / part03 < prev    next >
SHell self-extracting ARchive  |  1992-12-17  |  58.1 KB

view JSON data     |     view as text     |     open on a Mac     |     open on a PC

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: part03

ConfidenceProgramDetectionMatch TypeSupport
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 46 72 |.sources|.misc.Fr|
|00000020| 6f 6d 3a 20 6a 70 65 67 | 2d 69 6e 66 6f 40 75 75 |om: jpeg|-info@uu|
|00000030| 6e 65 74 2e 75 75 2e 6e | 65 74 20 28 49 6e 64 65 |net.uu.n|et (Inde|
|00000040| 70 65 6e 64 65 6e 74 20 | 4a 50 45 47 20 47 72 6f |pendent |JPEG Gro|
|00000050| 75 70 29 0a 53 75 62 6a | 65 63 74 3a 20 20 76 33 |up).Subj|ect: v3|
|00000060| 34 69 30 35 37 3a 20 20 | 6a 70 65 67 20 2d 20 4a |4i057: |jpeg - J|
|00000070| 50 45 47 20 69 6d 61 67 | 65 20 63 6f 6d 70 72 65 |PEG imag|e compre|
|00000080| 73 73 69 6f 6e 2c 20 50 | 61 72 74 30 33 2f 31 38 |ssion, P|art03/18|
|00000090| 0a 4d 65 73 73 61 67 65 | 2d 49 44 3a 20 3c 31 39 |.Message|-ID: <19|
|000000a0| 39 32 44 65 63 31 37 2e | 30 34 31 36 30 39 2e 32 |92Dec17.|041609.2|
|000000b0| 33 32 33 33 40 73 70 61 | 72 6b 79 2e 69 6d 64 2e |3233@spa|rky.imd.|
|000000c0| 73 74 65 72 6c 69 6e 67 | 2e 63 6f 6d 3e 0a 58 2d |sterling|.com>.X-|
|000000d0| 4d 64 34 2d 53 69 67 6e | 61 74 75 72 65 3a 20 39 |Md4-Sign|ature: 9|
|000000e0| 66 38 64 32 65 31 37 62 | 61 64 37 35 62 31 34 64 |f8d2e17b|ad75b14d|
|000000f0| 30 33 64 31 35 61 64 35 | 30 65 65 39 66 38 38 0a |03d15ad5|0ee9f88.|
|00000100| 44 61 74 65 3a 20 54 68 | 75 2c 20 31 37 20 44 65 |Date: Th|u, 17 De|
|00000110| 63 20 31 39 39 32 20 30 | 34 3a 31 36 3a 30 39 20 |c 1992 0|4:16:09 |
|00000120| 47 4d 54 0a 41 70 70 72 | 6f 76 65 64 3a 20 6b 65 |GMT.Appr|oved: ke|
|00000130| 6e 74 40 73 70 61 72 6b | 79 2e 69 6d 64 2e 73 74 |nt@spark|y.imd.st|
|00000140| 65 72 6c 69 6e 67 2e 63 | 6f 6d 0a 0a 53 75 62 6d |erling.c|om..Subm|
|00000150| 69 74 74 65 64 2d 62 79 | 3a 20 6a 70 65 67 2d 69 |itted-by|: jpeg-i|
|00000160| 6e 66 6f 40 75 75 6e 65 | 74 2e 75 75 2e 6e 65 74 |nfo@uune|t.uu.net|
|00000170| 20 28 49 6e 64 65 70 65 | 6e 64 65 6e 74 20 4a 50 | (Indepe|ndent JP|
|00000180| 45 47 20 47 72 6f 75 70 | 29 0a 50 6f 73 74 69 6e |EG Group|).Postin|
|00000190| 67 2d 6e 75 6d 62 65 72 | 3a 20 56 6f 6c 75 6d 65 |g-number|: Volume|
|000001a0| 20 33 34 2c 20 49 73 73 | 75 65 20 35 37 0a 41 72 | 34, Iss|ue 57.Ar|
|000001b0| 63 68 69 76 65 2d 6e 61 | 6d 65 3a 20 6a 70 65 67 |chive-na|me: jpeg|
|000001c0| 2f 70 61 72 74 30 33 0a | 45 6e 76 69 72 6f 6e 6d |/part03.|Environm|
|000001d0| 65 6e 74 3a 20 55 4e 49 | 58 2c 20 56 4d 53 2c 20 |ent: UNI|X, VMS, |
|000001e0| 4d 53 2d 44 4f 53 2c 20 | 4d 61 63 2c 20 41 6d 69 |MS-DOS, |Mac, Ami|
|000001f0| 67 61 2c 20 41 74 61 72 | 69 2c 20 43 72 61 79 0a |ga, Atar|i, Cray.|
|00000200| 53 75 70 65 72 73 65 64 | 65 73 3a 20 6a 70 65 67 |Supersed|es: jpeg|
|00000210| 3a 20 56 6f 6c 75 6d 65 | 20 32 39 2c 20 49 73 73 |: Volume| 29, Iss|
|00000220| 75 65 20 31 2d 31 38 0a | 0a 23 21 20 2f 62 69 6e |ue 1-18.|.#! /bin|
|00000230| 2f 73 68 0a 23 20 54 68 | 69 73 20 69 73 20 61 20 |/sh.# Th|is is a |
|00000240| 73 68 65 6c 6c 20 61 72 | 63 68 69 76 65 2e 20 20 |shell ar|chive. |
|00000250| 52 65 6d 6f 76 65 20 61 | 6e 79 74 68 69 6e 67 20 |Remove a|nything |
|00000260| 62 65 66 6f 72 65 20 74 | 68 69 73 20 6c 69 6e 65 |before t|his line|
|00000270| 2c 20 74 68 65 6e 20 66 | 65 65 64 20 69 74 0a 23 |, then f|eed it.#|
|00000280| 20 69 6e 74 6f 20 61 20 | 73 68 65 6c 6c 20 76 69 | into a |shell vi|
|00000290| 61 20 22 73 68 20 66 69 | 6c 65 22 20 6f 72 20 73 |a "sh fi|le" or s|
|000002a0| 69 6d 69 6c 61 72 2e 20 | 20 54 6f 20 6f 76 65 72 |imilar. | To over|
|000002b0| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 20 66 |write ex|isting f|
|000002c0| 69 6c 65 73 2c 0a 23 20 | 74 79 70 65 20 22 73 68 |iles,.# |type "sh|
|000002d0| 20 66 69 6c 65 20 2d 63 | 22 2e 0a 23 20 43 6f 6e | file -c|"..# Con|
|000002e0| 74 65 6e 74 73 3a 20 20 | 61 72 63 68 69 74 65 63 |tents: |architec|
|000002f0| 74 75 72 65 2e 42 20 6a | 63 64 65 66 6c 74 73 2e |ture.B j|cdeflts.|
|00000300| 63 20 6a 76 65 72 73 69 | 6f 6e 2e 68 0a 23 20 57 |c jversi|on.h.# W|
|00000310| 72 61 70 70 65 64 20 62 | 79 20 6b 65 6e 74 40 73 |rapped b|y kent@s|
|00000320| 70 61 72 6b 79 20 6f 6e | 20 57 65 64 20 44 65 63 |parky on| Wed Dec|
|00000330| 20 31 36 20 32 30 3a 35 | 32 3a 32 35 20 31 39 39 | 16 20:5|2:25 199|
|00000340| 32 0a 50 41 54 48 3d 2f | 62 69 6e 3a 2f 75 73 72 |2.PATH=/|bin:/usr|
|00000350| 2f 62 69 6e 3a 2f 75 73 | 72 2f 75 63 62 3a 2f 75 |/bin:/us|r/ucb:/u|
|00000360| 73 72 2f 6c 6f 63 61 6c | 2f 62 69 6e 3a 2f 75 73 |sr/local|/bin:/us|
|00000370| 72 2f 6c 62 69 6e 20 3b | 20 65 78 70 6f 72 74 20 |r/lbin ;| export |
|00000380| 50 41 54 48 0a 65 63 68 | 6f 20 49 66 20 74 68 69 |PATH.ech|o If thi|
|00000390| 73 20 61 72 63 68 69 76 | 65 20 69 73 20 63 6f 6d |s archiv|e is com|
|000003a0| 70 6c 65 74 65 2c 20 79 | 6f 75 20 77 69 6c 6c 20 |plete, y|ou will |
|000003b0| 73 65 65 20 74 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |see the |followin|
|000003c0| 67 20 6d 65 73 73 61 67 | 65 3a 0a 65 63 68 6f 20 |g messag|e:.echo |
|000003d0| 27 20 20 20 20 20 20 20 | 20 20 20 22 73 68 61 72 |' | "shar|
|000003e0| 3a 20 45 6e 64 20 6f 66 | 20 61 72 63 68 69 76 65 |: End of| archive|
|000003f0| 20 33 20 28 6f 66 20 31 | 38 29 2e 22 27 0a 69 66 | 3 (of 1|8)."'.if|
|00000400| 20 74 65 73 74 20 2d 66 | 20 27 61 72 63 68 69 74 | test -f| 'archit|
|00000410| 65 63 74 75 72 65 2e 42 | 27 20 2d 61 20 22 24 7b |ecture.B|' -a "${|
|00000420| 31 7d 22 20 21 3d 20 22 | 2d 63 22 20 3b 20 74 68 |1}" != "|-c" ; th|
|00000430| 65 6e 20 0a 20 20 65 63 | 68 6f 20 73 68 61 72 3a |en . ec|ho shar:|
|00000440| 20 57 69 6c 6c 20 6e 6f | 74 20 63 6c 6f 62 62 65 | Will no|t clobbe|
|00000450| 72 20 65 78 69 73 74 69 | 6e 67 20 66 69 6c 65 20 |r existi|ng file |
|00000460| 5c 22 27 61 72 63 68 69 | 74 65 63 74 75 72 65 2e |\"'archi|tecture.|
|00000470| 42 27 5c 22 0a 65 6c 73 | 65 0a 20 20 65 63 68 6f |B'\".els|e. echo|
|00000480| 20 73 68 61 72 3a 20 45 | 78 74 72 61 63 74 69 6e | shar: E|xtractin|
|00000490| 67 20 5c 22 27 61 72 63 | 68 69 74 65 63 74 75 72 |g \"'arc|hitectur|
|000004a0| 65 2e 42 27 5c 22 20 5c | 28 34 30 34 36 31 20 63 |e.B'\" \|(40461 c|
|000004b0| 68 61 72 61 63 74 65 72 | 73 5c 29 0a 20 20 73 65 |haracter|s\). se|
|000004c0| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 27 61 72 63 |d "s/^X/|/" >'arc|
|000004d0| 68 69 74 65 63 74 75 72 | 65 2e 42 27 20 3c 3c 27 |hitectur|e.B' <<'|
|000004e0| 45 4e 44 5f 4f 46 5f 46 | 49 4c 45 27 0a 58 0a 58 |END_OF_F|ILE'.X.X|
|000004f0| 46 6f 72 20 73 69 6d 69 | 6c 61 72 20 72 65 61 73 |For simi|lar reas|
|00000500| 6f 6e 73 2c 20 6f 6e 65 | 20 4d 43 55 20 69 73 20 |ons, one| MCU is |
|00000510| 61 6c 73 6f 20 74 68 65 | 20 62 65 73 74 20 63 68 |also the| best ch|
|00000520| 75 6e 6b 20 73 69 7a 65 | 20 66 6f 72 20 74 68 65 |unk size| for the|
|00000530| 20 66 72 65 71 75 65 6e | 63 79 0a 58 63 6f 65 66 | frequen|cy.Xcoef|
|00000540| 66 69 63 69 65 6e 74 20 | 71 75 61 6e 74 69 7a 61 |ficient |quantiza|
|00000550| 74 69 6f 6e 20 61 6e 64 | 20 64 65 71 75 61 6e 74 |tion and| dequant|
|00000560| 69 7a 61 74 69 6f 6e 20 | 73 74 65 70 73 2e 0a 58 |ization |steps..X|
|00000570| 0a 58 46 6f 72 20 64 6f | 77 6e 73 61 6d 70 6c 69 |.XFor do|wnsampli|
|00000580| 6e 67 20 61 6e 64 20 75 | 70 73 61 6d 70 6c 69 6e |ng and u|psamplin|
|00000590| 67 2c 20 74 68 65 20 62 | 65 73 74 20 63 68 75 6e |g, the b|est chun|
|000005a0| 6b 20 73 69 7a 65 20 69 | 73 20 74 6f 20 68 61 76 |k size i|s to hav|
|000005b0| 65 20 65 61 63 68 20 63 | 61 6c 6c 0a 58 74 72 61 |e each c|all.Xtra|
|000005c0| 6e 73 66 6f 72 6d 20 56 | 6b 20 73 61 6d 70 6c 65 |nsform V|k sample|
|000005d0| 20 72 6f 77 73 20 66 72 | 6f 6d 20 6f 72 20 74 6f | rows fr|om or to|
|000005e0| 20 56 6d 61 78 20 73 61 | 6d 70 6c 65 20 72 6f 77 | Vmax sa|mple row|
|000005f0| 73 20 28 56 6b 20 3d 20 | 74 68 69 73 20 63 6f 6d |s (Vk = |this com|
|00000600| 70 6f 6e 65 6e 74 27 73 | 0a 58 76 65 72 74 69 63 |ponent's|.Xvertic|
|00000610| 61 6c 20 73 61 6d 70 6c | 69 6e 67 20 66 61 63 74 |al sampl|ing fact|
|00000620| 6f 72 2c 20 56 6d 61 78 | 20 3d 20 6c 61 72 67 65 |or, Vmax| = large|
|00000630| 73 74 20 76 65 72 74 69 | 63 61 6c 20 73 61 6d 70 |st verti|cal samp|
|00000640| 6c 69 6e 67 20 66 61 63 | 74 6f 72 29 2e 20 20 54 |ling fac|tor). T|
|00000650| 68 65 72 65 20 61 72 65 | 0a 58 65 69 67 68 74 20 |here are|.Xeight |
|00000660| 73 75 63 68 20 63 68 75 | 6e 6b 73 20 69 6e 20 65 |such chu|nks in e|
|00000670| 61 63 68 20 4d 43 55 20 | 72 6f 77 2e 20 20 55 73 |ach MCU |row. Us|
|00000680| 69 6e 67 20 61 20 77 68 | 6f 6c 65 20 4d 43 55 20 |ing a wh|ole MCU |
|00000690| 72 6f 77 20 61 73 20 74 | 68 65 20 63 68 75 6e 6b |row as t|he chunk|
|000006a0| 20 73 69 7a 65 0a 58 77 | 6f 75 6c 64 20 72 65 64 | size.Xw|ould red|
|000006b0| 75 63 65 20 66 75 6e 63 | 74 69 6f 6e 20 63 61 6c |uce func|tion cal|
|000006c0| 6c 20 6f 76 65 72 68 65 | 61 64 20 61 20 66 72 61 |l overhe|ad a fra|
|000006d0| 63 74 69 6f 6e 2c 20 62 | 75 74 20 77 6f 75 6c 64 |ction, b|ut would|
|000006e0| 20 69 6d 70 6c 79 20 6d | 6f 72 65 20 62 75 66 66 | imply m|ore buff|
|000006f0| 65 72 69 6e 67 0a 58 74 | 6f 20 70 72 6f 76 69 64 |ering.Xt|o provid|
|00000700| 65 20 63 6f 6e 74 65 78 | 74 20 66 6f 72 20 63 72 |e contex|t for cr|
|00000710| 6f 73 73 2d 70 69 78 65 | 6c 20 73 6d 6f 6f 74 68 |oss-pixe|l smooth|
|00000720| 69 6e 67 2e 0a 58 0a 58 | 0a 58 2a 2a 2a 20 43 6f |ing..X.X|.X*** Co|
|00000730| 6d 70 72 65 73 73 69 6f | 6e 20 6f 62 6a 65 63 74 |mpressio|n object|
|00000740| 20 73 74 72 75 63 74 75 | 72 65 20 2a 2a 2a 0a 58 | structu|re ***.X|
|00000750| 0a 58 49 20 70 72 6f 70 | 6f 73 65 20 74 68 65 20 |.XI prop|ose the |
|00000760| 66 6f 6c 6c 6f 77 69 6e | 67 20 73 65 74 20 6f 66 |followin|g set of|
|00000770| 20 6f 62 6a 65 63 74 73 | 20 66 6f 72 20 74 68 65 | objects| for the|
|00000780| 20 63 6f 6d 70 72 65 73 | 73 6f 72 2e 20 20 48 65 | compres|sor. He|
|00000790| 72 65 20 61 6e 20 22 6f | 62 6a 65 63 74 22 0a 58 |re an "o|bject".X|
|000007a0| 69 73 20 74 68 65 20 63 | 6f 6d 6d 6f 6e 20 69 6e |is the c|ommon in|
|000007b0| 74 65 72 66 61 63 65 20 | 66 6f 72 20 6f 6e 65 20 |terface |for one |
|000007c0| 6f 72 20 6d 6f 72 65 20 | 6d 6f 64 75 6c 65 73 20 |or more |modules |
|000007d0| 68 61 76 69 6e 67 20 63 | 6f 6d 70 61 72 61 62 6c |having c|omparabl|
|000007e0| 65 20 66 75 6e 63 74 69 | 6f 6e 73 2e 0a 58 0a 58 |e functi|ons..X.X|
|000007f0| 4d 6f 73 74 20 6f 66 20 | 74 68 65 73 65 20 6f 62 |Most of |these ob|
|00000800| 6a 65 63 74 73 20 63 61 | 6e 20 62 65 20 6a 75 73 |jects ca|n be jus|
|00000810| 74 69 66 69 65 64 20 61 | 73 20 69 6e 66 6f 72 6d |tified a|s inform|
|00000820| 61 74 69 6f 6e 2d 68 69 | 64 69 6e 67 20 6d 6f 64 |ation-hi|ding mod|
|00000830| 75 6c 65 73 2e 0a 58 49 | 27 76 65 20 69 6e 64 69 |ules..XI|'ve indi|
|00000840| 63 61 74 65 64 20 77 68 | 61 74 20 69 6e 66 6f 72 |cated wh|at infor|
|00000850| 6d 61 74 69 6f 6e 20 69 | 73 20 70 72 69 76 61 74 |mation i|s privat|
|00000860| 65 20 74 6f 20 65 61 63 | 68 20 6f 62 6a 65 63 74 |e to eac|h object|
|00000870| 2f 6d 6f 64 75 6c 65 2e | 0a 58 0a 58 4e 6f 74 65 |/module.|.X.XNote|
|00000880| 20 74 68 61 74 20 69 6e | 20 61 6c 6c 20 63 61 73 | that in| all cas|
|00000890| 65 73 2c 20 74 68 65 20 | 63 61 6c 6c 65 72 20 6f |es, the |caller o|
|000008a0| 66 20 61 20 6d 65 74 68 | 6f 64 20 69 73 20 65 78 |f a meth|od is ex|
|000008b0| 70 65 63 74 65 64 20 74 | 6f 20 68 61 76 65 20 61 |pected t|o have a|
|000008c0| 6c 6c 6f 63 61 74 65 64 | 0a 58 61 6e 79 20 73 74 |llocated|.Xany st|
|000008d0| 6f 72 61 67 65 20 6e 65 | 65 64 65 64 20 66 6f 72 |orage ne|eded for|
|000008e0| 20 69 74 20 74 6f 20 72 | 65 74 75 72 6e 20 69 74 | it to r|eturn it|
|000008f0| 73 20 72 65 73 75 6c 74 | 2e 20 20 28 54 79 70 69 |s result|. (Typi|
|00000900| 63 61 6c 6c 79 20 74 68 | 69 73 20 73 74 6f 72 61 |cally th|is stora|
|00000910| 67 65 20 63 61 6e 0a 58 | 62 65 20 72 65 2d 75 73 |ge can.X|be re-us|
|00000920| 65 64 20 69 6e 20 73 75 | 63 63 65 73 73 69 76 65 |ed in su|ccessive|
|00000930| 20 63 61 6c 6c 73 2c 20 | 73 6f 20 6d 61 6c 6c 6f | calls, |so mallo|
|00000940| 63 27 69 6e 67 20 61 6e | 64 20 66 72 65 65 27 69 |c'ing an|d free'i|
|00000950| 6e 67 20 6f 6e 63 65 20 | 70 65 72 20 63 61 6c 6c |ng once |per call|
|00000960| 20 69 73 0a 58 6e 6f 74 | 20 72 65 61 73 6f 6e 61 | is.Xnot| reasona|
|00000970| 62 6c 65 2e 29 20 20 41 | 6c 73 6f 2c 20 6d 75 63 |ble.) A|lso, muc|
|00000980| 68 20 6f 66 20 74 68 65 | 20 63 6f 6e 74 65 78 74 |h of the| context|
|00000990| 20 72 65 71 75 69 72 65 | 64 20 28 63 6f 6d 70 72 | require|d (compr|
|000009a0| 65 73 73 69 6f 6e 20 70 | 61 72 61 6d 65 74 65 72 |ession p|arameter|
|000009b0| 73 2c 0a 58 69 6d 61 67 | 65 20 73 69 7a 65 2c 20 |s,.Ximag|e size, |
|000009c0| 65 74 63 29 20 77 69 6c | 6c 20 62 65 20 70 61 73 |etc) wil|l be pas|
|000009d0| 73 65 64 20 61 72 6f 75 | 6e 64 20 69 6e 20 6c 61 |sed arou|nd in la|
|000009e0| 72 67 65 20 63 6f 6d 6d | 6f 6e 20 64 61 74 61 20 |rge comm|on data |
|000009f0| 73 74 72 75 63 74 75 72 | 65 73 2c 20 77 68 69 63 |structur|es, whic|
|00000a00| 68 0a 58 61 72 65 6e 27 | 74 20 64 65 73 63 72 69 |h.Xaren'|t descri|
|00000a10| 62 65 64 20 68 65 72 65 | 3b 20 73 65 65 20 74 68 |bed here|; see th|
|00000a20| 65 20 68 65 61 64 65 72 | 20 66 69 6c 65 73 2e 20 |e header| files. |
|00000a30| 20 4e 6f 74 69 63 65 20 | 74 68 61 74 20 61 6e 79 | Notice |that any|
|00000a40| 20 6f 62 6a 65 63 74 20 | 74 68 61 74 0a 58 6d 69 | object |that.Xmi|
|00000a50| 67 68 74 20 6e 65 65 64 | 20 74 6f 20 61 6c 6c 6f |ght need| to allo|
|00000a60| 63 61 74 65 20 77 6f 72 | 6b 69 6e 67 20 73 74 6f |cate wor|king sto|
|00000a70| 72 61 67 65 20 72 65 63 | 65 69 76 65 73 20 61 6e |rage rec|eives an|
|00000a80| 20 22 69 6e 69 74 22 20 | 61 6e 64 20 61 20 22 74 | "init" |and a "t|
|00000a90| 65 72 6d 22 20 63 61 6c | 6c 3b 0a 58 22 74 65 72 |erm" cal|l;.X"ter|
|00000aa0| 6d 22 20 73 68 6f 75 6c | 64 20 62 65 20 63 61 72 |m" shoul|d be car|
|00000ab0| 65 66 75 6c 20 74 6f 20 | 66 72 65 65 20 61 6c 6c |eful to |free all|
|00000ac0| 20 61 6c 6c 6f 63 61 74 | 65 64 20 73 74 6f 72 61 | allocat|ed stora|
|00000ad0| 67 65 20 73 6f 20 74 68 | 61 74 20 74 68 65 20 4a |ge so th|at the J|
|00000ae0| 50 45 47 20 73 79 73 74 | 65 6d 0a 58 63 61 6e 20 |PEG syst|em.Xcan |
|00000af0| 62 65 20 75 73 65 64 20 | 6d 75 6c 74 69 70 6c 65 |be used |multiple|
|00000b00| 20 74 69 6d 65 73 20 64 | 75 72 69 6e 67 20 61 20 | times d|uring a |
|00000b10| 70 72 6f 67 72 61 6d 20 | 72 75 6e 2e 20 20 28 46 |program |run. (F|
|00000b20| 6f 72 20 74 68 65 20 73 | 61 6d 65 20 72 65 61 73 |or the s|ame reas|
|00000b30| 6f 6e 2c 0a 58 64 65 70 | 65 6e 64 69 6e 67 20 6f |on,.Xdep|ending o|
|00000b40| 6e 20 73 74 61 74 69 63 | 20 69 6e 69 74 69 61 6c |n static| initial|
|00000b50| 69 7a 61 74 69 6f 6e 20 | 6f 66 20 76 61 72 69 61 |ization |of varia|
|00000b60| 62 6c 65 73 20 69 73 20 | 61 20 6e 6f 2d 6e 6f 2e |bles is |a no-no.|
|00000b70| 20 20 54 68 65 20 6f 6e | 6c 79 0a 58 65 78 63 65 | The on|ly.Xexce|
|00000b80| 70 74 69 6f 6e 20 74 6f | 20 74 68 65 20 66 72 65 |ption to| the fre|
|00000b90| 65 2d 61 6c 6c 2d 61 6c | 6c 6f 63 61 74 65 64 2d |e-all-al|located-|
|00000ba0| 73 74 6f 72 61 67 65 20 | 72 75 6c 65 20 69 73 20 |storage |rule is |
|00000bb0| 74 68 61 74 20 73 74 6f | 72 61 67 65 20 61 6c 6c |that sto|rage all|
|00000bc0| 6f 63 61 74 65 64 20 66 | 6f 72 0a 58 74 68 65 20 |ocated f|or.Xthe |
|00000bd0| 65 6e 74 69 72 65 20 70 | 72 6f 63 65 73 73 69 6e |entire p|rocessin|
|00000be0| 67 20 6f 66 20 61 6e 20 | 69 6d 61 67 65 20 6e 65 |g of an |image ne|
|00000bf0| 65 64 20 6e 6f 74 20 62 | 65 20 65 78 70 6c 69 63 |ed not b|e explic|
|00000c00| 69 74 6c 79 20 66 72 65 | 65 64 2c 20 73 69 6e 63 |itly fre|ed, sinc|
|00000c10| 65 20 74 68 65 0a 58 6d | 65 6d 6f 72 79 20 6d 61 |e the.Xm|emory ma|
|00000c20| 6e 61 67 65 72 27 73 20 | 66 72 65 65 5f 61 6c 6c |nager's |free_all|
|00000c30| 20 63 6c 65 61 6e 75 70 | 20 77 69 6c 6c 20 66 72 | cleanup| will fr|
|00000c40| 65 65 20 69 74 2e 29 0a | 58 0a 58 31 2e 20 49 6e |ee it.).|X.X1. In|
|00000c50| 70 75 74 20 66 69 6c 65 | 20 63 6f 6e 76 65 72 73 |put file| convers|
|00000c60| 69 6f 6e 20 74 6f 20 73 | 74 61 6e 64 61 72 64 69 |ion to s|tandardi|
|00000c70| 7a 65 64 20 66 6f 72 6d | 2e 20 20 54 68 69 73 20 |zed form|. This |
|00000c80| 70 72 6f 76 69 64 65 73 | 20 74 68 65 73 65 20 6d |provides| these m|
|00000c90| 65 74 68 6f 64 73 3a 0a | 58 09 69 6e 70 75 74 5f |ethods:.|X.input_|
|00000ca0| 69 6e 69 74 3a 20 72 65 | 61 64 20 74 68 65 20 66 |init: re|ad the f|
|00000cb0| 69 6c 65 20 68 65 61 64 | 65 72 2c 20 72 65 70 6f |ile head|er, repo|
|00000cc0| 72 74 20 69 6d 61 67 65 | 20 73 69 7a 65 20 26 20 |rt image| size & |
|00000cd0| 63 6f 6d 70 6f 6e 65 6e | 74 20 63 6f 75 6e 74 2e |componen|t count.|
|00000ce0| 0a 58 09 67 65 74 5f 69 | 6e 70 75 74 5f 72 6f 77 |.X.get_i|nput_row|
|00000cf0| 3a 20 72 65 61 64 20 6f | 6e 65 20 70 69 78 65 6c |: read o|ne pixel|
|00000d00| 20 72 6f 77 2c 20 72 65 | 74 75 72 6e 20 69 74 20 | row, re|turn it |
|00000d10| 69 6e 20 6f 75 72 20 73 | 74 61 6e 64 61 72 64 20 |in our s|tandard |
|00000d20| 66 6f 72 6d 61 74 2e 0a | 58 09 69 6e 70 75 74 5f |format..|X.input_|
|00000d30| 74 65 72 6d 3a 20 66 69 | 6e 69 73 68 20 75 70 20 |term: fi|nish up |
|00000d40| 61 74 20 74 68 65 20 65 | 6e 64 2e 0a 58 20 20 20 |at the e|nd..X |
|00000d50| 49 6e 20 69 6d 70 6c 65 | 6d 65 6e 74 61 74 69 6f |In imple|mentatio|
|00000d60| 6e 73 20 74 68 61 74 20 | 73 75 70 70 6f 72 74 20 |ns that |support |
|00000d70| 6d 75 6c 74 69 70 6c 65 | 20 69 6e 70 75 74 20 66 |multiple| input f|
|00000d80| 6f 72 6d 61 74 73 2c 20 | 69 6e 70 75 74 5f 69 6e |ormats, |input_in|
|00000d90| 69 74 20 63 6f 75 6c 64 | 0a 58 20 20 20 73 65 74 |it could|.X set|
|00000da0| 20 75 70 20 61 6e 20 61 | 70 70 72 6f 70 72 69 61 | up an a|ppropria|
|00000db0| 74 65 20 67 65 74 5f 69 | 6e 70 75 74 5f 72 6f 77 |te get_i|nput_row|
|00000dc0| 20 6d 65 74 68 6f 64 20 | 64 65 70 65 6e 64 69 6e | method |dependin|
|00000dd0| 67 20 6f 6e 20 74 68 65 | 20 66 6f 72 6d 61 74 20 |g on the| format |
|00000de0| 69 74 0a 58 20 20 20 66 | 69 6e 64 73 2e 20 20 4e |it.X f|inds. N|
|00000df0| 6f 74 65 20 74 68 61 74 | 20 69 6e 20 6d 6f 73 74 |ote that| in most|
|00000e00| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 73 2c 20 74 | applica|tions, t|
|00000e10| 68 65 20 73 65 6c 65 63 | 74 69 6f 6e 20 61 6e 64 |he selec|tion and|
|00000e20| 20 6f 70 65 6e 69 6e 67 | 20 6f 66 20 74 68 65 0a | opening| of the.|
|00000e30| 58 20 20 20 69 6e 70 75 | 74 20 66 69 6c 65 20 77 |X inpu|t file w|
|00000e40| 69 6c 6c 20 62 65 20 75 | 6e 64 65 72 20 74 68 65 |ill be u|nder the|
|00000e50| 20 63 6f 6e 74 72 6f 6c | 20 6f 66 20 74 68 65 20 | control| of the |
|00000e60| 75 73 65 72 20 69 6e 74 | 65 72 66 61 63 65 20 6d |user int|erface m|
|00000e70| 6f 64 75 6c 65 3b 20 61 | 6e 64 0a 58 20 20 20 69 |odule; a|nd.X i|
|00000e80| 6e 64 65 65 64 20 74 68 | 65 20 75 73 65 72 20 69 |ndeed th|e user i|
|00000e90| 6e 74 65 72 66 61 63 65 | 20 6d 61 79 20 68 61 76 |nterface| may hav|
|00000ea0| 65 20 61 6c 72 65 61 64 | 79 20 72 65 61 64 20 74 |e alread|y read t|
|00000eb0| 68 65 20 69 6e 70 75 74 | 20 68 65 61 64 65 72 2c |he input| header,|
|00000ec0| 20 73 6f 20 74 68 61 74 | 0a 58 20 20 20 61 6c 6c | so that|.X all|
|00000ed0| 20 74 68 61 74 20 69 6e | 70 75 74 5f 69 6e 69 74 | that in|put_init|
|00000ee0| 20 6d 61 79 20 68 61 76 | 65 20 74 6f 20 64 6f 20 | may hav|e to do |
|00000ef0| 69 73 20 72 65 74 75 72 | 6e 20 70 72 65 76 69 6f |is retur|n previo|
|00000f00| 75 73 6c 79 20 73 61 76 | 65 64 20 76 61 6c 75 65 |usly sav|ed value|
|00000f10| 73 2e 20 20 54 68 65 0a | 58 20 20 20 62 65 68 69 |s. The.|X behi|
|00000f20| 6e 64 2d 74 68 65 2d 73 | 63 65 6e 65 73 20 69 6e |nd-the-s|cenes in|
|00000f30| 74 65 72 61 63 74 69 6f | 6e 20 62 65 74 77 65 65 |teractio|n betwee|
|00000f40| 6e 20 74 68 69 73 20 6f | 62 6a 65 63 74 20 61 6e |n this o|bject an|
|00000f50| 64 20 74 68 65 20 75 73 | 65 72 20 69 6e 74 65 72 |d the us|er inter|
|00000f60| 66 61 63 65 20 69 73 0a | 58 20 20 20 6e 6f 74 20 |face is.|X not |
|00000f70| 73 70 65 63 69 66 69 65 | 64 20 62 79 20 74 68 69 |specifie|d by thi|
|00000f80| 73 20 61 72 63 68 69 74 | 65 63 74 75 72 65 2e 0a |s archit|ecture..|
|00000f90| 58 20 20 20 28 48 69 64 | 65 73 20 66 6f 72 6d 61 |X (Hid|es forma|
|00000fa0| 74 20 6f 66 20 69 6e 70 | 75 74 20 69 6d 61 67 65 |t of inp|ut image|
|00000fb0| 20 61 6e 64 20 6d 65 63 | 68 61 6e 69 73 6d 20 75 | and mec|hanism u|
|00000fc0| 73 65 64 20 74 6f 20 72 | 65 61 64 20 69 74 2e 20 |sed to r|ead it. |
|00000fd0| 20 54 68 69 73 20 63 6f | 64 65 20 69 73 0a 58 20 | This co|de is.X |
|00000fe0| 20 20 6c 69 6b 65 6c 79 | 20 74 6f 20 76 61 72 79 | likely| to vary|
|00000ff0| 20 63 6f 6e 73 69 64 65 | 72 61 62 6c 79 20 66 72 | conside|rably fr|
|00001000| 6f 6d 20 6f 6e 65 20 69 | 6d 70 6c 65 6d 65 6e 74 |om one i|mplement|
|00001010| 61 74 69 6f 6e 20 74 6f | 20 61 6e 6f 74 68 65 72 |ation to| another|
|00001020| 2e 20 20 4e 6f 74 65 20 | 74 68 61 74 0a 58 20 20 |. Note |that.X |
|00001030| 20 74 68 65 20 63 6f 6c | 6f 72 20 73 70 61 63 65 | the col|or space|
|00001040| 20 61 6e 64 20 6e 75 6d | 62 65 72 20 6f 66 20 63 | and num|ber of c|
|00001050| 6f 6c 6f 72 20 63 6f 6d | 70 6f 6e 65 6e 74 73 20 |olor com|ponents |
|00001060| 6f 66 20 74 68 65 20 73 | 6f 75 72 63 65 20 61 72 |of the s|ource ar|
|00001070| 65 20 6e 6f 74 20 68 69 | 64 64 65 6e 3b 0a 58 20 |e not hi|dden;.X |
|00001080| 20 20 62 75 74 20 74 68 | 65 79 20 61 72 65 20 75 | but th|ey are u|
|00001090| 73 65 64 20 6f 6e 6c 79 | 20 62 79 20 74 68 65 20 |sed only| by the |
|000010a0| 6e 65 78 74 20 6f 62 6a | 65 63 74 2e 29 0a 58 0a |next obj|ect.).X.|
|000010b0| 58 32 2e 20 47 61 6d 6d | 61 20 61 6e 64 20 63 6f |X2. Gamm|a and co|
|000010c0| 6c 6f 72 20 73 70 61 63 | 65 20 63 6f 6e 76 65 72 |lor spac|e conver|
|000010d0| 73 69 6f 6e 2e 20 20 54 | 68 69 73 20 70 72 6f 76 |sion. T|his prov|
|000010e0| 69 64 65 73 20 74 68 72 | 65 65 20 6d 65 74 68 6f |ides thr|ee metho|
|000010f0| 64 73 3a 0a 58 09 63 6f | 6c 6f 72 69 6e 5f 69 6e |ds:.X.co|lorin_in|
|00001100| 69 74 3a 20 69 6e 69 74 | 69 61 6c 69 7a 61 74 69 |it: init|ializati|
|00001110| 6f 6e 2e 0a 58 09 67 65 | 74 5f 73 61 6d 70 6c 65 |on..X.ge|t_sample|
|00001120| 5f 72 6f 77 73 3a 20 72 | 65 61 64 2c 20 63 6f 6e |_rows: r|ead, con|
|00001130| 76 65 72 74 2c 20 61 6e | 64 20 72 65 74 75 72 6e |vert, an|d return|
|00001140| 20 61 20 73 70 65 63 69 | 66 69 65 64 20 6e 75 6d | a speci|fied num|
|00001150| 62 65 72 20 6f 66 20 70 | 69 78 65 6c 0a 58 09 09 |ber of p|ixel.X..|
|00001160| 09 20 72 6f 77 73 20 28 | 6e 6f 74 20 6d 6f 72 65 |. rows (|not more|
|00001170| 20 74 68 61 6e 20 72 65 | 6d 61 69 6e 20 69 6e 20 | than re|main in |
|00001180| 74 68 65 20 70 69 63 74 | 75 72 65 29 2e 0a 58 09 |the pict|ure)..X.|
|00001190| 63 6f 6c 6f 72 69 6e 5f | 74 65 72 6d 3a 20 66 69 |colorin_|term: fi|
|000011a0| 6e 69 73 68 20 75 70 20 | 61 74 20 74 68 65 20 65 |nish up |at the e|
|000011b0| 6e 64 2e 0a 58 20 20 20 | 54 68 65 20 6d 6f 73 74 |nd..X |The most|
|000011c0| 20 65 66 66 69 63 69 65 | 6e 74 20 61 70 70 72 6f | efficie|nt appro|
|000011d0| 61 63 68 20 73 65 65 6d | 73 20 74 6f 20 62 65 20 |ach seem|s to be |
|000011e0| 66 6f 72 20 74 68 69 73 | 20 6f 62 6a 65 63 74 20 |for this| object |
|000011f0| 74 6f 20 63 61 6c 6c 0a | 58 20 20 20 67 65 74 5f |to call.|X get_|
|00001200| 69 6e 70 75 74 5f 72 6f | 77 20 64 69 72 65 63 74 |input_ro|w direct|
|00001210| 6c 79 2c 20 72 61 74 68 | 65 72 20 74 68 61 6e 20 |ly, rath|er than |
|00001220| 62 65 69 6e 67 20 70 61 | 73 73 65 64 20 74 68 65 |being pa|ssed the|
|00001230| 20 69 6e 70 75 74 20 64 | 61 74 61 3b 20 74 68 61 | input d|ata; tha|
|00001240| 74 20 77 61 79 2c 0a 58 | 20 20 20 61 6e 79 20 69 |t way,.X| any i|
|00001250| 6e 74 65 72 6d 65 64 69 | 61 74 65 20 73 74 6f 72 |ntermedi|ate stor|
|00001260| 61 67 65 20 72 65 71 75 | 69 72 65 64 20 63 61 6e |age requ|ired can|
|00001270| 20 62 65 20 6c 6f 63 61 | 6c 20 74 6f 20 74 68 69 | be loca|l to thi|
|00001280| 73 20 6f 62 6a 65 63 74 | 2e 0a 58 20 20 20 28 67 |s object|..X (g|
|00001290| 65 74 5f 73 61 6d 70 6c | 65 5f 72 6f 77 73 20 6d |et_sampl|e_rows m|
|000012a0| 69 67 68 74 20 74 65 6c | 6c 20 67 65 74 5f 69 6e |ight tel|l get_in|
|000012b0| 70 75 74 5f 72 6f 77 20 | 74 6f 20 72 65 61 64 20 |put_row |to read |
|000012c0| 64 69 72 65 63 74 6c 79 | 20 69 6e 74 6f 20 69 74 |directly| into it|
|000012d0| 73 20 6f 77 6e 0a 58 20 | 20 20 6f 75 74 70 75 74 |s own.X | output|
|000012e0| 20 61 72 65 61 20 61 6e | 64 20 74 68 65 6e 20 63 | area an|d then c|
|000012f0| 6f 6e 76 65 72 74 20 69 | 6e 20 70 6c 61 63 65 3b |onvert i|n place;|
|00001300| 20 6f 72 20 69 74 20 6d | 61 79 20 64 6f 20 73 6f | or it m|ay do so|
|00001310| 6d 65 74 68 69 6e 67 20 | 64 69 66 66 65 72 65 6e |mething |differen|
|00001320| 74 2e 0a 58 20 20 20 46 | 6f 72 20 65 78 61 6d 70 |t..X F|or examp|
|00001330| 6c 65 2c 20 63 6f 6e 76 | 65 72 73 69 6f 6e 20 69 |le, conv|ersion i|
|00001340| 6e 20 70 6c 61 63 65 20 | 77 6f 75 6c 64 6e 27 74 |n place |wouldn't|
|00001350| 20 77 6f 72 6b 20 69 66 | 20 69 74 20 69 73 20 63 | work if| it is c|
|00001360| 68 61 6e 67 69 6e 67 20 | 74 68 65 20 6e 75 6d 62 |hanging |the numb|
|00001370| 65 72 0a 58 20 20 20 6f | 66 20 63 6f 6c 6f 72 20 |er.X o|f color |
|00001380| 63 6f 6d 70 6f 6e 65 6e | 74 73 2e 29 20 20 54 68 |componen|ts.) Th|
|00001390| 65 20 6f 75 74 70 75 74 | 20 6f 66 20 74 68 69 73 |e output| of this|
|000013a0| 20 73 74 65 70 20 69 73 | 20 69 6e 20 74 68 65 20 | step is| in the |
|000013b0| 73 74 61 6e 64 61 72 64 | 69 7a 65 64 0a 58 20 20 |standard|ized.X |
|000013c0| 20 73 61 6d 70 6c 65 20 | 61 72 72 61 79 20 66 6f | sample |array fo|
|000013d0| 72 6d 61 74 20 73 68 6f | 77 6e 20 70 72 65 76 69 |rmat sho|wn previ|
|000013e0| 6f 75 73 6c 79 2e 0a 58 | 20 20 20 28 48 69 64 65 |ously..X| (Hide|
|000013f0| 73 20 61 6c 6c 20 6b 6e | 6f 77 6c 65 64 67 65 20 |s all kn|owledge |
|00001400| 6f 66 20 63 6f 6c 6f 72 | 20 73 70 61 63 65 20 73 |of color| space s|
|00001410| 65 6d 61 6e 74 69 63 73 | 20 61 6e 64 20 63 6f 6e |emantics| and con|
|00001420| 76 65 72 73 69 6f 6e 2e | 20 20 52 65 6d 61 69 6e |version.| Remain|
|00001430| 69 6e 67 0a 58 20 20 20 | 6d 6f 64 75 6c 65 73 20 |ing.X |modules |
|00001440| 6f 6e 6c 79 20 6e 65 65 | 64 20 74 6f 20 6b 6e 6f |only nee|d to kno|
|00001450| 77 20 74 68 65 20 6e 75 | 6d 62 65 72 20 6f 66 20 |w the nu|mber of |
|00001460| 4a 50 45 47 20 63 6f 6d | 70 6f 6e 65 6e 74 73 2e |JPEG com|ponents.|
|00001470| 29 0a 58 0a 58 33 2e 20 | 45 64 67 65 20 65 78 70 |).X.X3. |Edge exp|
|00001480| 61 6e 73 69 6f 6e 3a 20 | 6e 65 65 64 73 20 6f 6e |ansion: |needs on|
|00001490| 6c 79 20 61 20 73 69 6e | 67 6c 65 20 6d 65 74 68 |ly a sin|gle meth|
|000014a0| 6f 64 2e 0a 58 09 65 64 | 67 65 5f 65 78 70 61 6e |od..X.ed|ge_expan|
|000014b0| 64 3a 20 47 69 76 65 6e | 20 61 6e 20 4e 78 4d 20 |d: Given| an NxM |
|000014c0| 73 61 6d 70 6c 65 20 61 | 72 72 61 79 2c 20 65 78 |sample a|rray, ex|
|000014d0| 70 61 6e 64 20 74 6f 20 | 61 20 64 65 73 69 72 65 |pand to |a desire|
|000014e0| 64 20 73 69 7a 65 20 28 | 61 0a 58 09 09 20 20 20 |d size (|a.X.. |
|000014f0| 20 20 6d 75 6c 74 69 70 | 6c 65 20 6f 66 20 74 68 | multip|le of th|
|00001500| 65 20 4d 43 55 20 64 69 | 6d 65 6e 73 69 6f 6e 73 |e MCU di|mensions|
|00001510| 29 20 62 79 20 64 75 70 | 6c 69 63 61 74 69 6e 67 |) by dup|licating|
|00001520| 20 74 68 65 20 6c 61 73 | 74 0a 58 09 09 20 20 20 | the las|t.X.. |
|00001530| 20 20 72 6f 77 20 6f 72 | 20 63 6f 6c 75 6d 6e 2e | row or| column.|
|00001540| 20 20 52 65 70 65 61 74 | 20 66 6f 72 20 65 61 63 | Repeat| for eac|
|00001550| 68 20 63 6f 6d 70 6f 6e | 65 6e 74 2e 0a 58 20 20 |h compon|ent..X |
|00001560| 20 45 78 70 61 6e 73 69 | 6f 6e 20 77 69 6c 6c 20 | Expansi|on will |
|00001570| 6f 63 63 75 72 20 69 6e | 20 70 6c 61 63 65 2c 20 |occur in| place, |
|00001580| 73 6f 20 74 68 65 20 63 | 61 6c 6c 65 72 20 6d 75 |so the c|aller mu|
|00001590| 73 74 20 68 61 76 65 20 | 70 72 65 2d 61 6c 6c 6f |st have |pre-allo|
|000015a0| 63 61 74 65 64 20 65 6e | 6f 75 67 68 0a 58 20 20 |cated en|ough.X |
|000015b0| 20 73 74 6f 72 61 67 65 | 2e 20 20 28 49 27 6d 20 | storage|. (I'm |
|000015c0| 61 73 73 75 6d 69 6e 67 | 20 74 68 61 74 20 69 74 |assuming| that it|
|000015d0| 20 69 73 20 65 61 73 69 | 65 72 20 61 6e 64 20 66 | is easi|er and f|
|000015e0| 61 73 74 65 72 20 74 6f | 20 64 6f 20 74 68 69 73 |aster to| do this|
|000015f0| 20 65 78 70 61 6e 73 69 | 6f 6e 0a 58 20 20 20 74 | expansi|on.X t|
|00001600| 68 61 6e 20 69 74 20 69 | 73 20 74 6f 20 77 6f 72 |han it i|s to wor|
|00001610| 72 79 20 61 62 6f 75 74 | 20 62 6f 75 6e 64 61 72 |ry about| boundar|
|00001620| 79 20 63 6f 6e 64 69 74 | 69 6f 6e 73 20 69 6e 20 |y condit|ions in |
|00001630| 74 68 65 20 6e 65 78 74 | 20 74 77 6f 20 73 74 65 |the next| two ste|
|00001640| 70 73 2e 0a 58 20 20 20 | 4e 6f 74 69 63 65 20 74 |ps..X |Notice t|
|00001650| 68 61 74 20 76 65 72 74 | 69 63 61 6c 20 65 78 70 |hat vert|ical exp|
|00001660| 61 6e 73 69 6f 6e 20 77 | 69 6c 6c 20 6f 63 63 75 |ansion w|ill occu|
|00001670| 72 20 6f 6e 6c 79 20 6f | 6e 63 65 2c 20 61 74 20 |r only o|nce, at |
|00001680| 74 68 65 20 62 6f 74 74 | 6f 6d 20 6f 66 20 74 68 |the bott|om of th|
|00001690| 65 0a 58 20 20 20 70 69 | 63 74 75 72 65 2c 20 73 |e.X pi|cture, s|
|000016a0| 6f 20 6f 6e 6c 79 20 68 | 6f 72 69 7a 6f 6e 74 61 |o only h|orizonta|
|000016b0| 6c 20 65 78 70 61 6e 73 | 69 6f 6e 20 62 79 20 61 |l expans|ion by a|
|000016c0| 20 66 65 77 20 70 69 78 | 65 6c 73 20 69 73 20 73 | few pix|els is s|
|000016d0| 70 65 65 64 2d 63 72 69 | 74 69 63 61 6c 2e 29 0a |peed-cri|tical.).|
|000016e0| 58 20 20 20 28 54 68 69 | 73 20 64 6f 65 73 6e 27 |X (Thi|s doesn'|
|000016f0| 74 20 72 65 61 6c 6c 79 | 20 68 69 64 65 20 61 6e |t really| hide an|
|00001700| 79 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 2c 20 73 |y inform|ation, s|
|00001710| 6f 20 6d 61 79 62 65 20 | 69 74 20 63 6f 75 6c 64 |o maybe |it could|
|00001720| 20 62 65 20 61 20 73 69 | 6d 70 6c 65 0a 58 20 20 | be a si|mple.X |
|00001730| 20 73 75 62 72 6f 75 74 | 69 6e 65 20 69 6e 73 74 | subrout|ine inst|
|00001740| 65 61 64 20 6f 66 20 61 | 20 6d 65 74 68 6f 64 2e |ead of a| method.|
|00001750| 20 20 44 65 70 65 6e 64 | 73 20 6f 6e 20 77 68 65 | Depend|s on whe|
|00001760| 74 68 65 72 20 77 65 20 | 77 61 6e 74 20 74 6f 20 |ther we |want to |
|00001770| 62 65 20 61 62 6c 65 20 | 74 6f 0a 58 20 20 20 75 |be able |to.X u|
|00001780| 73 65 20 61 6c 74 65 72 | 6e 61 74 69 76 65 2c 20 |se alter|native, |
|00001790| 6f 70 74 69 6d 69 7a 65 | 64 20 6d 65 74 68 6f 64 |optimize|d method|
|000017a0| 73 2e 29 0a 58 0a 58 34 | 2e 20 44 6f 77 6e 73 61 |s.).X.X4|. Downsa|
|000017b0| 6d 70 6c 69 6e 67 3a 20 | 74 68 69 73 20 77 69 6c |mpling: |this wil|
|000017c0| 6c 20 62 65 20 61 70 70 | 6c 69 65 64 20 74 6f 20 |l be app|lied to |
|000017d0| 6f 6e 65 20 63 6f 6d 70 | 6f 6e 65 6e 74 20 61 74 |one comp|onent at|
|000017e0| 20 61 20 74 69 6d 65 2e | 0a 58 09 64 6f 77 6e 73 | a time.|.X.downs|
|000017f0| 61 6d 70 6c 65 5f 69 6e | 69 74 3a 20 69 6e 69 74 |ample_in|it: init|
|00001800| 69 61 6c 69 7a 65 20 28 | 70 72 65 63 61 6c 63 75 |ialize (|precalcu|
|00001810| 6c 61 74 65 20 63 6f 6e | 76 6f 6c 75 74 69 6f 6e |late con|volution|
|00001820| 20 66 61 63 74 6f 72 73 | 2c 20 66 6f 72 0a 58 09 | factors|, for.X.|
|00001830| 09 09 20 65 78 61 6d 70 | 6c 65 29 2e 20 20 54 68 |.. examp|le). Th|
|00001840| 69 73 20 77 69 6c 6c 20 | 62 65 20 63 61 6c 6c 65 |is will |be calle|
|00001850| 64 20 6f 6e 63 65 20 70 | 65 72 20 73 63 61 6e 2e |d once p|er scan.|
|00001860| 0a 58 09 64 6f 77 6e 73 | 61 6d 70 6c 65 3a 20 47 |.X.downs|ample: G|
|00001870| 69 76 65 6e 20 61 20 73 | 61 6d 70 6c 65 20 61 72 |iven a s|ample ar|
|00001880| 72 61 79 2c 20 72 65 64 | 75 63 65 20 69 74 20 74 |ray, red|uce it t|
|00001890| 6f 20 61 20 73 6d 61 6c | 6c 65 72 20 6e 75 6d 62 |o a smal|ler numb|
|000018a0| 65 72 20 6f 66 0a 58 09 | 09 20 20 20 20 73 61 6d |er of.X.|. sam|
|000018b0| 70 6c 65 73 20 75 73 69 | 6e 67 20 73 70 65 63 69 |ples usi|ng speci|
|000018c0| 66 69 65 64 20 73 61 6d | 70 6c 69 6e 67 20 66 61 |fied sam|pling fa|
|000018d0| 63 74 6f 72 73 2e 0a 58 | 09 64 6f 77 6e 73 61 6d |ctors..X|.downsam|
|000018e0| 70 6c 65 5f 74 65 72 6d | 3a 20 63 6c 65 61 6e 20 |ple_term|: clean |
|000018f0| 75 70 20 61 74 20 74 68 | 65 20 65 6e 64 20 6f 66 |up at th|e end of|
|00001900| 20 61 20 73 63 61 6e 2e | 0a 58 20 20 20 49 66 20 | a scan.|.X If |
|00001910| 74 68 65 20 63 75 72 72 | 65 6e 74 20 63 6f 6d 70 |the curr|ent comp|
|00001920| 6f 6e 65 6e 74 20 68 61 | 73 20 76 65 72 74 69 63 |onent ha|s vertic|
|00001930| 61 6c 20 73 61 6d 70 6c | 69 6e 67 20 66 61 63 74 |al sampl|ing fact|
|00001940| 6f 72 20 56 6b 20 61 6e | 64 20 74 68 65 20 6c 61 |or Vk an|d the la|
|00001950| 72 67 65 73 74 0a 58 20 | 20 20 73 61 6d 70 6c 69 |rgest.X | sampli|
|00001960| 6e 67 20 66 61 63 74 6f | 72 20 69 73 20 56 6d 61 |ng facto|r is Vma|
|00001970| 78 2c 20 74 68 65 6e 20 | 74 68 65 20 69 6e 70 75 |x, then |the inpu|
|00001980| 74 20 69 73 20 61 6c 77 | 61 79 73 20 56 6d 61 78 |t is alw|ays Vmax|
|00001990| 20 73 61 6d 70 6c 65 20 | 72 6f 77 73 20 28 77 68 | sample |rows (wh|
|000019a0| 6f 73 65 0a 58 20 20 20 | 77 69 64 74 68 20 69 73 |ose.X |width is|
|000019b0| 20 61 20 6d 75 6c 74 69 | 70 6c 65 20 6f 66 20 48 | a multi|ple of H|
|000019c0| 6d 61 78 29 20 61 6e 64 | 20 74 68 65 20 6f 75 74 |max) and| the out|
|000019d0| 70 75 74 20 69 73 20 61 | 6c 77 61 79 73 20 56 6b |put is a|lways Vk|
|000019e0| 20 73 61 6d 70 6c 65 20 | 72 6f 77 73 2e 0a 58 20 | sample |rows..X |
|000019f0| 20 20 56 6d 61 78 20 61 | 64 64 69 74 69 6f 6e 61 | Vmax a|dditiona|
|00001a00| 6c 20 72 6f 77 73 20 61 | 62 6f 76 65 20 61 6e 64 |l rows a|bove and|
|00001a10| 20 62 65 6c 6f 77 20 74 | 68 65 20 6e 6f 6d 69 6e | below t|he nomin|
|00001a20| 61 6c 20 69 6e 70 75 74 | 20 72 6f 77 73 20 61 72 |al input| rows ar|
|00001a30| 65 20 61 6c 73 6f 20 70 | 61 73 73 65 64 0a 58 20 |e also p|assed.X |
|00001a40| 20 20 66 6f 72 20 75 73 | 65 20 62 79 20 70 61 72 | for us|e by par|
|00001a50| 74 69 61 6c 2d 70 69 78 | 65 6c 2d 61 76 65 72 61 |tial-pix|el-avera|
|00001a60| 67 69 6e 67 20 73 61 6d | 70 6c 69 6e 67 20 6d 65 |ging sam|pling me|
|00001a70| 74 68 6f 64 73 2e 20 20 | 28 49 73 20 74 68 69 73 |thods. |(Is this|
|00001a80| 20 6e 65 63 65 73 73 61 | 72 79 3f 29 0a 58 20 20 | necessa|ry?).X |
|00001a90| 20 41 74 20 74 68 65 20 | 74 6f 70 20 61 6e 64 20 | At the |top and |
|00001aa0| 62 6f 74 74 6f 6d 20 6f | 66 20 74 68 65 20 69 6d |bottom o|f the im|
|00001ab0| 61 67 65 2c 20 74 68 65 | 73 65 20 65 78 74 72 61 |age, the|se extra|
|00001ac0| 20 72 6f 77 73 20 61 72 | 65 20 63 6f 70 69 65 73 | rows ar|e copies|
|00001ad0| 20 6f 66 20 74 68 65 0a | 58 20 20 20 66 69 72 73 | of the.|X firs|
|00001ae0| 74 20 6f 72 20 6c 61 73 | 74 20 61 63 74 75 61 6c |t or las|t actual|
|00001af0| 20 69 6e 70 75 74 20 72 | 6f 77 2e 0a 58 20 20 20 | input r|ow..X |
|00001b00| 28 54 68 69 73 20 68 69 | 64 65 73 20 77 68 65 74 |(This hi|des whet|
|00001b10| 68 65 72 20 61 6e 64 20 | 68 6f 77 20 63 72 6f 73 |her and |how cros|
|00001b20| 73 2d 70 69 78 65 6c 20 | 61 76 65 72 61 67 69 6e |s-pixel |averagin|
|00001b30| 67 20 6f 63 63 75 72 73 | 2e 29 0a 58 0a 58 35 2e |g occurs|.).X.X5.|
|00001b40| 20 4d 43 55 20 65 78 74 | 72 61 63 74 69 6f 6e 20 | MCU ext|raction |
|00001b50| 28 63 72 65 61 74 69 6f | 6e 20 6f 66 20 61 20 73 |(creatio|n of a s|
|00001b60| 69 6e 67 6c 65 20 73 65 | 71 75 65 6e 63 65 20 6f |ingle se|quence o|
|00001b70| 66 20 38 78 38 20 73 61 | 6d 70 6c 65 20 62 6c 6f |f 8x8 sa|mple blo|
|00001b80| 63 6b 73 29 2e 0a 58 09 | 65 78 74 72 61 63 74 5f |cks)..X.|extract_|
|00001b90| 69 6e 69 74 3a 20 69 6e | 69 74 69 61 6c 69 7a 65 |init: in|itialize|
|00001ba0| 20 61 73 20 6e 65 65 64 | 65 64 2e 20 20 54 68 69 | as need|ed. Thi|
|00001bb0| 73 20 77 69 6c 6c 20 62 | 65 20 63 61 6c 6c 65 64 |s will b|e called|
|00001bc0| 20 6f 6e 63 65 20 70 65 | 72 20 73 63 61 6e 2e 0a | once pe|r scan..|
|00001bd0| 58 09 65 78 74 72 61 63 | 74 5f 4d 43 55 73 3a 20 |X.extrac|t_MCUs: |
|00001be0| 63 6f 6e 76 65 72 74 20 | 61 20 73 61 6d 70 6c 65 |convert |a sample|
|00001bf0| 20 61 72 72 61 79 20 74 | 6f 20 61 20 73 65 71 75 | array t|o a sequ|
|00001c00| 65 6e 63 65 20 6f 66 20 | 4d 43 55 73 2e 0a 58 09 |ence of |MCUs..X.|
|00001c10| 65 78 74 72 61 63 74 5f | 74 65 72 6d 3a 20 63 6c |extract_|term: cl|
|00001c20| 65 61 6e 20 75 70 20 61 | 74 20 74 68 65 20 65 6e |ean up a|t the en|
|00001c30| 64 20 6f 66 20 61 20 73 | 63 61 6e 2e 0a 58 20 20 |d of a s|can..X |
|00001c40| 20 47 69 76 65 6e 20 6f | 6e 65 20 6f 72 20 6d 6f | Given o|ne or mo|
|00001c50| 72 65 20 4d 43 55 20 72 | 6f 77 73 20 77 6f 72 74 |re MCU r|ows wort|
|00001c60| 68 20 6f 66 20 69 6d 61 | 67 65 20 64 61 74 61 2c |h of ima|ge data,|
|00001c70| 20 65 78 74 72 61 63 74 | 20 73 61 6d 70 6c 65 20 | extract| sample |
|00001c80| 62 6c 6f 63 6b 73 20 69 | 6e 20 74 68 65 0a 58 20 |blocks i|n the.X |
|00001c90| 20 20 61 70 70 72 6f 70 | 72 69 61 74 65 20 6f 72 | approp|riate or|
|00001ca0| 64 65 72 3b 20 70 61 73 | 73 20 74 68 65 73 65 20 |der; pas|s these |
|00001cb0| 6f 66 66 20 74 6f 20 73 | 75 62 73 65 71 75 65 6e |off to s|ubsequen|
|00001cc0| 74 20 73 74 65 70 73 20 | 6f 6e 65 20 4d 43 55 20 |t steps |one MCU |
|00001cd0| 61 74 20 61 20 74 69 6d | 65 2e 0a 58 20 20 20 54 |at a tim|e..X T|
|00001ce0| 68 65 20 69 6e 70 75 74 | 20 6d 75 73 74 20 62 65 |he input| must be|
|00001cf0| 20 61 20 6d 75 6c 74 69 | 70 6c 65 20 6f 66 20 74 | a multi|ple of t|
|00001d00| 68 65 20 4d 43 55 20 64 | 69 6d 65 6e 73 69 6f 6e |he MCU d|imension|
|00001d10| 73 2e 20 20 49 74 20 77 | 69 6c 6c 20 70 72 6f 62 |s. It w|ill prob|
|00001d20| 61 62 6c 79 20 62 65 0a | 58 20 20 20 6d 6f 73 74 |ably be.|X most|
|00001d30| 20 63 6f 6e 76 65 6e 69 | 65 6e 74 20 66 6f 72 20 | conveni|ent for |
|00001d40| 74 68 65 20 44 43 54 20 | 74 72 61 6e 73 66 6f 72 |the DCT |transfor|
|00001d50| 6d 2c 20 66 72 65 71 75 | 65 6e 63 79 20 71 75 61 |m, frequ|ency qua|
|00001d60| 6e 74 69 7a 61 74 69 6f | 6e 2c 20 61 6e 64 20 7a |ntizatio|n, and z|
|00001d70| 69 67 7a 61 67 0a 58 20 | 20 20 72 65 6f 72 64 65 |igzag.X | reorde|
|00001d80| 72 69 6e 67 20 6f 66 20 | 65 61 63 68 20 62 6c 6f |ring of |each blo|
|00001d90| 63 6b 20 74 6f 20 62 65 | 20 64 6f 6e 65 20 61 73 |ck to be| done as|
|00001da0| 20 73 69 6d 70 6c 65 20 | 73 75 62 72 6f 75 74 69 | simple |subrouti|
|00001db0| 6e 65 73 20 6f 66 20 74 | 68 69 73 20 73 74 65 70 |nes of t|his step|
|00001dc0| 2e 0a 58 20 20 20 4f 6e | 63 65 20 61 20 74 72 61 |..X On|ce a tra|
|00001dd0| 6e 73 66 6f 72 6d 65 64 | 20 4d 43 55 20 68 61 73 |nsformed| MCU has|
|00001de0| 20 62 65 65 6e 20 63 6f | 6d 70 6c 65 74 65 64 2c | been co|mpleted,|
|00001df0| 20 69 74 27 6c 6c 20 62 | 65 20 70 61 73 73 65 64 | it'll b|e passed|
|00001e00| 20 6f 66 66 20 74 6f 20 | 61 0a 58 20 20 20 6d 65 | off to |a.X me|
|00001e10| 74 68 6f 64 20 63 61 6c | 6c 2c 20 77 68 69 63 68 |thod cal|l, which|
|00001e20| 20 77 69 6c 6c 20 62 65 | 20 70 61 73 73 65 64 20 | will be| passed |
|00001e30| 61 73 20 61 20 70 61 72 | 61 6d 65 74 65 72 20 74 |as a par|ameter t|
|00001e40| 6f 20 65 78 74 72 61 63 | 74 5f 4d 43 55 73 2e 0a |o extrac|t_MCUs..|
|00001e50| 58 20 20 20 54 68 61 74 | 20 72 6f 75 74 69 6e 65 |X That| routine|
|00001e60| 20 6d 69 67 68 74 20 65 | 69 74 68 65 72 20 65 6e | might e|ither en|
|00001e70| 63 6f 64 65 20 61 6e 64 | 20 6f 75 74 70 75 74 20 |code and| output |
|00001e80| 74 68 65 20 4d 43 55 20 | 69 6d 6d 65 64 69 61 74 |the MCU |immediat|
|00001e90| 65 6c 79 2c 20 6f 72 20 | 62 75 66 66 65 72 0a 58 |ely, or |buffer.X|
|00001ea0| 20 20 20 69 74 20 75 70 | 20 66 6f 72 20 6c 61 74 | it up| for lat|
|00001eb0| 65 72 20 6f 75 74 70 75 | 74 20 69 66 20 77 65 20 |er outpu|t if we |
|00001ec0| 77 61 6e 74 20 74 6f 20 | 64 6f 20 67 6c 6f 62 61 |want to |do globa|
|00001ed0| 6c 20 6f 70 74 69 6d 69 | 7a 61 74 69 6f 6e 20 6f |l optimi|zation o|
|00001ee0| 66 20 74 68 65 20 65 6e | 74 72 6f 70 79 0a 58 20 |f the en|tropy.X |
|00001ef0| 20 20 65 6e 63 6f 64 69 | 6e 67 20 63 6f 65 66 66 | encodi|ng coeff|
|00001f00| 69 63 69 65 6e 74 73 2e | 20 20 4e 6f 74 65 3a 20 |icients.| Note: |
|00001f10| 77 68 65 6e 20 6f 75 74 | 70 75 74 74 69 6e 67 20 |when out|putting |
|00001f20| 61 20 6e 6f 6e 69 6e 74 | 65 72 6c 65 61 76 65 64 |a nonint|erleaved|
|00001f30| 20 66 69 6c 65 20 74 68 | 69 73 0a 58 20 20 20 6f | file th|is.X o|
|00001f40| 62 6a 65 63 74 20 77 69 | 6c 6c 20 62 65 20 63 61 |bject wi|ll be ca|
|00001f50| 6c 6c 65 64 20 73 65 70 | 61 72 61 74 65 6c 79 20 |lled sep|arately |
|00001f60| 66 6f 72 20 65 61 63 68 | 20 63 6f 6d 70 6f 6e 65 |for each| compone|
|00001f70| 6e 74 2e 20 20 44 69 72 | 65 63 74 20 6f 75 74 70 |nt. Dir|ect outp|
|00001f80| 75 74 20 63 6f 75 6c 64 | 0a 58 20 20 20 62 65 20 |ut could|.X be |
|00001f90| 64 6f 6e 65 20 66 6f 72 | 20 74 68 65 20 66 69 72 |done for| the fir|
|00001fa0| 73 74 20 63 6f 6d 70 6f | 6e 65 6e 74 2c 20 62 75 |st compo|nent, bu|
|00001fb0| 74 20 74 68 65 20 6f 74 | 68 65 72 73 20 77 6f 75 |t the ot|hers wou|
|00001fc0| 6c 64 20 68 61 76 65 20 | 74 6f 20 62 65 20 62 75 |ld have |to be bu|
|00001fd0| 66 66 65 72 65 64 2e 0a | 58 20 20 20 28 41 67 61 |ffered..|X (Aga|
|00001fe0| 69 6e 2c 20 61 6e 20 6f | 62 6a 65 63 74 20 6d 61 |in, an o|bject ma|
|00001ff0| 69 6e 6c 79 20 6f 6e 20 | 74 68 65 20 67 72 6f 75 |inly on |the grou|
|00002000| 6e 64 73 20 74 68 61 74 | 20 6d 75 6c 74 69 70 6c |nds that| multipl|
|00002010| 65 20 69 6e 73 74 61 6e | 74 69 61 74 69 6f 6e 73 |e instan|tiations|
|00002020| 20 6d 69 67 68 74 0a 58 | 20 20 20 62 65 20 75 73 | might.X| be us|
|00002030| 65 66 75 6c 2e 29 0a 58 | 0a 58 36 2e 20 44 43 54 |eful.).X|.X6. DCT|
|00002040| 20 74 72 61 6e 73 66 6f | 72 6d 61 74 69 6f 6e 20 | transfo|rmation |
|00002050| 6f 66 20 65 61 63 68 20 | 38 78 38 20 62 6c 6f 63 |of each |8x8 bloc|
|00002060| 6b 2e 20 20 54 68 69 73 | 20 70 72 6f 62 61 62 6c |k. This| probabl|
|00002070| 79 20 64 6f 65 73 6e 27 | 74 20 68 61 76 65 20 74 |y doesn'|t have t|
|00002080| 6f 20 62 65 20 61 0a 58 | 20 20 20 66 75 6c 6c 2d |o be a.X| full-|
|00002090| 66 6c 65 64 67 65 64 20 | 6d 65 74 68 6f 64 2c 20 |fledged |method, |
|000020a0| 62 75 74 20 6a 75 73 74 | 20 61 20 70 6c 61 69 6e |but just| a plain|
|000020b0| 20 73 75 62 72 6f 75 74 | 69 6e 65 20 74 68 61 74 | subrout|ine that|
|000020c0| 20 77 69 6c 6c 20 62 65 | 20 63 61 6c 6c 65 64 20 | will be| called |
|000020d0| 62 79 20 4d 43 55 0a 58 | 20 20 20 65 78 74 72 61 |by MCU.X| extra|
|000020e0| 63 74 69 6f 6e 2e 20 20 | 4f 6e 65 20 38 78 38 20 |ction. |One 8x8 |
|000020f0| 62 6c 6f 63 6b 20 77 69 | 6c 6c 20 62 65 20 70 72 |block wi|ll be pr|
|00002100| 6f 63 65 73 73 65 64 20 | 70 65 72 20 63 61 6c 6c |ocessed |per call|
|00002110| 2e 0a 58 0a 58 37 2e 20 | 51 75 61 6e 74 69 7a 61 |..X.X7. |Quantiza|
|00002120| 74 69 6f 6e 20 73 63 61 | 6c 69 6e 67 20 61 6e 64 |tion sca|ling and|
|00002130| 20 7a 69 67 7a 61 67 20 | 72 65 6f 72 64 65 72 69 | zigzag |reorderi|
|00002140| 6e 67 20 6f 66 20 74 68 | 65 20 65 6c 65 6d 65 6e |ng of th|e elemen|
|00002150| 74 73 20 69 6e 20 65 61 | 63 68 20 38 78 38 0a 58 |ts in ea|ch 8x8.X|
|00002160| 20 20 20 62 6c 6f 63 6b | 2e 20 20 28 54 68 69 73 | block|. (This|
|00002170| 20 63 61 6e 20 70 72 6f | 62 61 62 6c 79 20 62 65 | can pro|bably be|
|00002180| 20 61 20 70 6c 61 69 6e | 20 73 75 62 72 6f 75 74 | a plain| subrout|
|00002190| 69 6e 65 20 63 61 6c 6c | 65 64 20 6f 6e 63 65 20 |ine call|ed once |
|000021a0| 70 65 72 20 62 6c 6f 63 | 6b 20 62 79 0a 58 20 20 |per bloc|k by.X |
|000021b0| 20 4d 43 55 20 65 78 74 | 72 61 63 74 69 6f 6e 3b | MCU ext|raction;|
|000021c0| 20 68 61 72 64 20 74 6f | 20 73 65 65 20 61 20 6e | hard to| see a n|
|000021d0| 65 65 64 20 66 6f 72 20 | 6d 75 6c 74 69 70 6c 65 |eed for |multiple|
|000021e0| 20 69 6e 73 74 61 6e 74 | 69 61 74 69 6f 6e 73 20 | instant|iations |
|000021f0| 68 65 72 65 2e 29 0a 58 | 0a 58 38 2e 20 45 6e 74 |here.).X|.X8. Ent|
|00002200| 72 6f 70 79 20 65 6e 63 | 6f 64 69 6e 67 20 28 48 |ropy enc|oding (H|
|00002210| 75 66 66 6d 61 6e 20 6f | 72 20 61 72 69 74 68 6d |uffman o|r arithm|
|00002220| 65 74 69 63 29 2e 0a 58 | 09 65 6e 74 72 6f 70 79 |etic)..X|.entropy|
|00002230| 5f 65 6e 63 6f 64 65 5f | 69 6e 69 74 3a 20 70 72 |_encode_|init: pr|
|00002240| 65 70 61 72 65 20 66 6f | 72 20 6f 6e 65 20 73 63 |epare fo|r one sc|
|00002250| 61 6e 2e 0a 58 09 65 6e | 74 72 6f 70 79 5f 65 6e |an..X.en|tropy_en|
|00002260| 63 6f 64 65 3a 20 61 63 | 63 65 70 74 73 20 61 6e |code: ac|cepts an|
|00002270| 20 4d 43 55 27 73 20 77 | 6f 72 74 68 20 6f 66 20 | MCU's w|orth of |
|00002280| 71 75 61 6e 74 69 7a 65 | 64 20 63 6f 65 66 66 69 |quantize|d coeffi|
|00002290| 63 69 65 6e 74 73 2c 0a | 58 09 09 09 65 6e 63 6f |cients,.|X...enco|
|000022a0| 64 65 73 20 61 6e 64 20 | 6f 75 74 70 75 74 73 20 |des and |outputs |
|000022b0| 74 68 65 6d 2e 0a 58 09 | 65 6e 74 72 6f 70 79 5f |them..X.|entropy_|
|000022c0| 65 6e 63 6f 64 65 5f 74 | 65 72 6d 3a 20 66 69 6e |encode_t|erm: fin|
|000022d0| 69 73 68 20 75 70 20 61 | 74 20 65 6e 64 20 6f 66 |ish up a|t end of|
|000022e0| 20 61 20 73 63 61 6e 20 | 28 64 75 6d 70 20 61 6e | a scan |(dump an|
|000022f0| 79 20 62 75 66 66 65 72 | 65 64 0a 58 09 09 09 20 |y buffer|ed.X... |
|00002300| 20 20 20 20 62 79 74 65 | 73 2c 20 66 6f 72 20 65 | byte|s, for e|
|00002310| 78 61 6d 70 6c 65 29 2e | 0a 58 20 20 20 54 68 65 |xample).|.X The|
|00002320| 20 64 61 74 61 20 6f 75 | 74 70 75 74 20 62 79 20 | data ou|tput by |
|00002330| 74 68 69 73 20 6d 6f 64 | 75 6c 65 20 77 69 6c 6c |this mod|ule will|
|00002340| 20 62 65 20 73 65 6e 74 | 20 74 6f 20 74 68 65 20 | be sent| to the |
|00002350| 65 6e 74 72 6f 70 79 5f | 6f 75 74 70 75 74 20 6d |entropy_|output m|
|00002360| 65 74 68 6f 64 0a 58 20 | 20 20 70 72 6f 76 69 64 |ethod.X | provid|
|00002370| 65 64 20 62 79 20 74 68 | 65 20 70 69 70 65 6c 69 |ed by th|e pipeli|
|00002380| 6e 65 20 63 6f 6e 74 72 | 6f 6c 6c 65 72 2e 20 20 |ne contr|oller. |
|00002390| 28 49 74 20 77 69 6c 6c | 20 70 72 6f 62 61 62 6c |(It will| probabl|
|000023a0| 79 20 62 65 20 77 6f 72 | 74 68 20 75 73 69 6e 67 |y be wor|th using|
|000023b0| 0a 58 20 20 20 62 75 66 | 66 65 72 69 6e 67 20 74 |.X buf|fering t|
|000023c0| 6f 20 70 61 73 73 20 6d | 75 6c 74 69 70 6c 65 20 |o pass m|ultiple |
|000023d0| 62 79 74 65 73 20 70 65 | 72 20 63 61 6c 6c 20 6f |bytes pe|r call o|
|000023e0| 66 20 74 68 65 20 6f 75 | 74 70 75 74 20 6d 65 74 |f the ou|tput met|
|000023f0| 68 6f 64 2e 29 20 20 54 | 68 65 0a 58 20 20 20 6f |hod.) T|he.X o|
|00002400| 75 74 70 75 74 20 6d 65 | 74 68 6f 64 20 63 6f 75 |utput me|thod cou|
|00002410| 6c 64 20 62 65 20 6a 75 | 73 74 20 77 72 69 74 65 |ld be ju|st write|
|00002420| 5f 6a 70 65 67 5f 64 61 | 74 61 2c 20 62 75 74 20 |_jpeg_da|ta, but |
|00002430| 6d 69 67 68 74 20 61 6c | 73 6f 20 62 65 20 61 20 |might al|so be a |
|00002440| 64 75 6d 6d 79 0a 58 20 | 20 20 72 6f 75 74 69 6e |dummy.X | routin|
|00002450| 65 20 74 68 61 74 20 63 | 6f 75 6e 74 73 20 6f 75 |e that c|ounts ou|
|00002460| 74 70 75 74 20 62 79 74 | 65 73 20 28 66 6f 72 20 |tput byt|es (for |
|00002470| 75 73 65 20 64 75 72 69 | 6e 67 20 63 75 74 2d 61 |use duri|ng cut-a|
|00002480| 6e 64 2d 74 72 79 20 63 | 6f 65 66 66 69 63 69 65 |nd-try c|oefficie|
|00002490| 6e 74 0a 58 20 20 20 6f | 70 74 69 6d 69 7a 61 74 |nt.X o|ptimizat|
|000024a0| 69 6f 6e 29 2e 0a 58 20 | 20 20 28 54 68 69 73 20 |ion)..X | (This |
|000024b0| 68 69 64 65 73 20 77 68 | 69 63 68 20 65 6e 74 72 |hides wh|ich entr|
|000024c0| 6f 70 79 20 65 6e 63 6f | 64 69 6e 67 20 6d 65 74 |opy enco|ding met|
|000024d0| 68 6f 64 20 69 73 20 69 | 6e 20 75 73 65 2e 29 0a |hod is i|n use.).|
|000024e0| 58 0a 58 39 2e 20 4a 50 | 45 47 20 66 69 6c 65 20 |X.X9. JP|EG file |
|000024f0| 68 65 61 64 65 72 20 63 | 6f 6e 73 74 72 75 63 74 |header c|onstruct|
|00002500| 69 6f 6e 2e 20 20 54 68 | 69 73 20 77 69 6c 6c 20 |ion. Th|is will |
|00002510| 70 72 6f 76 69 64 65 20 | 74 68 65 73 65 20 6d 65 |provide |these me|
|00002520| 74 68 6f 64 73 3a 0a 58 | 09 77 72 69 74 65 5f 66 |thods:.X|.write_f|
|00002530| 69 6c 65 5f 68 65 61 64 | 65 72 3a 20 6f 75 74 70 |ile_head|er: outp|
|00002540| 75 74 20 74 68 65 20 69 | 6e 69 74 69 61 6c 20 68 |ut the i|nitial h|
|00002550| 65 61 64 65 72 2e 0a 58 | 09 77 72 69 74 65 5f 73 |eader..X|.write_s|
|00002560| 63 61 6e 5f 68 65 61 64 | 65 72 3a 20 6f 75 74 70 |can_head|er: outp|
|00002570| 75 74 20 73 63 61 6e 20 | 68 65 61 64 65 72 20 28 |ut scan |header (|
|00002580| 63 61 6c 6c 65 64 20 6f | 6e 63 65 20 70 65 72 20 |called o|nce per |
|00002590| 63 6f 6d 70 6f 6e 65 6e | 74 0a 58 09 09 09 20 20 |componen|t.X... |
|000025a0| 20 69 66 20 6e 6f 6e 69 | 6e 74 65 72 6c 65 61 76 | if noni|nterleav|
|000025b0| 65 64 20 6d 6f 64 65 29 | 2e 0a 58 09 77 72 69 74 |ed mode)|..X.writ|
|000025c0| 65 5f 6a 70 65 67 5f 64 | 61 74 61 3a 20 74 68 65 |e_jpeg_d|ata: the|
|000025d0| 20 61 63 74 75 61 6c 20 | 64 61 74 61 20 6f 75 74 | actual |data out|
|000025e0| 70 75 74 20 6d 65 74 68 | 6f 64 20 66 6f 72 20 74 |put meth|od for t|
|000025f0| 68 65 20 70 72 65 63 65 | 64 69 6e 67 20 73 74 65 |he prece|ding ste|
|00002600| 70 2e 0a 58 09 77 72 69 | 74 65 5f 73 63 61 6e 5f |p..X.wri|te_scan_|
|00002610| 74 72 61 69 6c 65 72 3a | 20 66 69 6e 69 73 68 20 |trailer:| finish |
|00002620| 75 70 20 61 66 74 65 72 | 20 6f 6e 65 20 73 63 61 |up after| one sca|
|00002630| 6e 2e 0a 58 09 77 72 69 | 74 65 5f 66 69 6c 65 5f |n..X.wri|te_file_|
|00002640| 74 72 61 69 6c 65 72 3a | 20 66 69 6e 69 73 68 20 |trailer:| finish |
|00002650| 75 70 20 61 74 20 65 6e | 64 20 6f 66 20 66 69 6c |up at en|d of fil|
|00002660| 65 2e 0a 58 20 20 20 4e | 6f 74 65 20 74 68 61 74 |e..X N|ote that|
|00002670| 20 63 6f 6d 70 72 65 73 | 73 65 64 20 64 61 74 61 | compres|sed data|
|00002680| 20 69 73 20 70 61 73 73 | 65 64 20 74 6f 20 74 68 | is pass|ed to th|
|00002690| 65 20 77 72 69 74 65 5f | 6a 70 65 67 5f 64 61 74 |e write_|jpeg_dat|
|000026a0| 61 20 6d 65 74 68 6f 64 | 2c 20 69 6e 20 63 61 73 |a method|, in cas|
|000026b0| 65 0a 58 20 20 20 61 20 | 73 69 6d 70 6c 65 20 66 |e.X a |simple f|
|000026c0| 77 72 69 74 65 20 69 73 | 6e 27 74 20 61 70 70 72 |write is|n't appr|
|000026d0| 6f 70 72 69 61 74 65 20 | 66 6f 72 20 73 6f 6d 65 |opriate |for some|
|000026e0| 20 72 65 61 73 6f 6e 2e | 0a 58 20 20 20 28 54 68 | reason.|.X (Th|
|000026f0| 69 73 20 68 69 64 65 73 | 20 77 68 69 63 68 20 76 |is hides| which v|
|00002700| 61 72 69 61 6e 74 20 4a | 50 45 47 20 66 69 6c 65 |ariant J|PEG file|
|00002710| 20 66 6f 72 6d 61 74 20 | 69 73 20 62 65 69 6e 67 | format |is being|
|00002720| 20 77 72 69 74 74 65 6e | 2e 20 20 41 6c 73 6f 2c | written|. Also,|
|00002730| 20 74 68 65 0a 58 20 20 | 20 61 63 74 75 61 6c 20 | the.X | actual |
|00002740| 6d 65 63 68 61 6e 69 73 | 6d 20 66 6f 72 20 77 72 |mechanis|m for wr|
|00002750| 69 74 69 6e 67 20 74 68 | 65 20 66 69 6c 65 20 69 |iting th|e file i|
|00002760| 73 20 70 72 69 76 61 74 | 65 20 74 6f 20 74 68 69 |s privat|e to thi|
|00002770| 73 20 6f 62 6a 65 63 74 | 20 61 6e 64 20 74 68 65 |s object| and the|
|00002780| 0a 58 20 20 20 75 73 65 | 72 20 69 6e 74 65 72 66 |.X use|r interf|
|00002790| 61 63 65 2e 29 0a 58 0a | 58 31 30 2e 20 50 69 70 |ace.).X.|X10. Pip|
|000027a0| 65 6c 69 6e 65 20 63 6f | 6e 74 72 6f 6c 2e 20 20 |eline co|ntrol. |
|000027b0| 54 68 69 73 20 6f 62 6a | 65 63 74 20 77 69 6c 6c |This obj|ect will|
|000027c0| 20 70 72 6f 76 69 64 65 | 20 74 68 65 20 22 6d 61 | provide| the "ma|
|000027d0| 69 6e 20 6c 6f 6f 70 22 | 20 74 68 61 74 20 69 6e |in loop"| that in|
|000027e0| 76 6f 6b 65 73 0a 58 20 | 20 20 20 61 6c 6c 20 74 |vokes.X | all t|
|000027f0| 68 65 20 70 69 70 65 6c | 69 6e 65 20 6f 62 6a 65 |he pipel|ine obje|
|00002800| 63 74 73 2e 20 20 4e 6f | 74 65 20 74 68 61 74 20 |cts. No|te that |
|00002810| 77 65 20 77 69 6c 6c 20 | 6e 65 65 64 20 73 65 76 |we will |need sev|
|00002820| 65 72 61 6c 20 64 69 66 | 66 65 72 65 6e 74 20 6d |eral dif|ferent m|
|00002830| 61 69 6e 0a 58 20 20 20 | 20 6c 6f 6f 70 73 20 64 |ain.X | loops d|
|00002840| 65 70 65 6e 64 69 6e 67 | 20 6f 6e 20 74 68 65 20 |epending| on the |
|00002850| 73 69 74 75 61 74 69 6f | 6e 20 28 69 6e 74 65 72 |situatio|n (inter|
|00002860| 6c 65 61 76 65 64 20 6f | 75 74 70 75 74 20 6f 72 |leaved o|utput or|
|00002870| 20 6e 6f 74 2c 20 67 6c | 6f 62 61 6c 0a 58 20 20 | not, gl|obal.X |
|00002880| 20 20 6f 70 74 69 6d 69 | 7a 61 74 69 6f 6e 20 6f | optimi|zation o|
|00002890| 66 20 65 6e 63 6f 64 69 | 6e 67 20 70 61 72 61 6d |f encodi|ng param|
|000028a0| 65 74 65 72 73 20 6f 72 | 20 6e 6f 74 2c 20 65 74 |eters or| not, et|
|000028b0| 63 29 2e 20 20 54 68 69 | 73 20 6f 62 6a 65 63 74 |c). Thi|s object|
|000028c0| 20 77 69 6c 6c 20 64 6f | 0a 58 20 20 20 20 6d 6f | will do|.X mo|
|000028d0| 73 74 20 6f 66 20 74 68 | 65 20 6d 65 6d 6f 72 79 |st of th|e memory|
|000028e0| 20 61 6c 6c 6f 63 61 74 | 69 6f 6e 2c 20 73 69 6e | allocat|ion, sin|
|000028f0| 63 65 20 69 74 20 77 69 | 6c 6c 20 70 72 6f 76 69 |ce it wi|ll provi|
|00002900| 64 65 20 74 68 65 20 77 | 6f 72 6b 69 6e 67 20 62 |de the w|orking b|
|00002910| 75 66 66 65 72 73 0a 58 | 20 20 20 20 74 68 61 74 |uffers.X| that|
|00002920| 20 61 72 65 20 74 68 65 | 20 69 6e 70 75 74 73 20 | are the| inputs |
|00002930| 61 6e 64 20 6f 75 74 70 | 75 74 73 20 6f 66 20 74 |and outp|uts of t|
|00002940| 68 65 20 70 69 70 65 6c | 69 6e 65 20 73 74 65 70 |he pipel|ine step|
|00002950| 73 2e 0a 58 20 20 20 20 | 28 41 6e 20 6f 62 6a 65 |s..X |(An obje|
|00002960| 63 74 20 6d 6f 73 74 6c | 79 20 74 6f 20 73 75 70 |ct mostl|y to sup|
|00002970| 70 6f 72 74 20 6d 75 6c | 74 69 70 6c 65 20 69 6e |port mul|tiple in|
|00002980| 73 74 61 6e 74 69 61 74 | 69 6f 6e 73 3b 20 68 6f |stantiat|ions; ho|
|00002990| 77 65 76 65 72 2c 20 6f | 76 65 72 61 6c 6c 0a 58 |wever, o|verall.X|
|000029a0| 20 20 20 20 6d 65 6d 6f | 72 79 20 6d 61 6e 61 67 | memo|ry manag|
|000029b0| 65 6d 65 6e 74 20 61 6e | 64 20 73 65 71 75 65 6e |ement an|d sequen|
|000029c0| 63 69 6e 67 20 6f 66 20 | 6f 70 65 72 61 74 69 6f |cing of |operatio|
|000029d0| 6e 73 20 61 72 65 20 6b | 6e 6f 77 6e 20 6f 6e 6c |ns are k|nown onl|
|000029e0| 79 20 68 65 72 65 2e 29 | 0a 58 0a 58 31 31 2e 20 |y here.)|.X.X11. |
|000029f0| 4f 76 65 72 61 6c 6c 20 | 63 6f 6e 74 72 6f 6c 2e |Overall |control.|
|00002a00| 20 20 54 68 69 73 20 6d | 6f 64 75 6c 65 20 77 69 | This m|odule wi|
|00002a10| 6c 6c 20 70 72 6f 76 69 | 64 65 20 61 74 20 6c 65 |ll provi|de at le|
|00002a20| 61 73 74 20 74 77 6f 20 | 72 6f 75 74 69 6e 65 73 |ast two |routines|
|00002a30| 3a 0a 58 09 6a 70 65 67 | 5f 63 6f 6d 70 72 65 73 |:.X.jpeg|_compres|
|00002a40| 73 3a 20 74 68 65 20 6d | 61 69 6e 20 65 6e 74 72 |s: the m|ain entr|
|00002a50| 79 20 70 6f 69 6e 74 20 | 74 6f 20 74 68 65 20 63 |y point |to the c|
|00002a60| 6f 6d 70 72 65 73 73 6f | 72 2e 0a 58 09 70 65 72 |ompresso|r..X.per|
|00002a70| 5f 73 63 61 6e 5f 6d 65 | 74 68 6f 64 5f 73 65 6c |_scan_me|thod_sel|
|00002a80| 65 63 74 69 6f 6e 3a 20 | 63 61 6c 6c 65 64 20 62 |ection: |called b|
|00002a90| 79 20 70 69 70 65 6c 69 | 6e 65 20 63 6f 6e 74 72 |y pipeli|ne contr|
|00002aa0| 6f 6c 6c 65 72 73 20 66 | 6f 72 0a 58 09 09 09 09 |ollers f|or.X....|
|00002ab0| 20 20 20 73 65 63 6f 6e | 64 61 72 79 20 6d 65 74 | secon|dary met|
|00002ac0| 68 6f 64 20 73 65 6c 65 | 63 74 69 6f 6e 20 70 61 |hod sele|ction pa|
|00002ad0| 73 73 65 73 2e 0a 58 20 | 20 20 20 6a 70 65 67 5f |sses..X | jpeg_|
|00002ae0| 63 6f 6d 70 72 65 73 73 | 20 69 73 20 69 6e 76 6f |compress| is invo|
|00002af0| 6b 65 64 20 66 72 6f 6d | 20 74 68 65 20 75 73 65 |ked from| the use|
|00002b00| 72 20 69 6e 74 65 72 66 | 61 63 65 20 61 66 74 65 |r interf|ace afte|
|00002b10| 72 20 74 68 65 20 55 49 | 20 68 61 73 20 73 65 6c |r the UI| has sel|
|00002b20| 65 63 74 65 64 0a 58 20 | 20 20 20 74 68 65 20 69 |ected.X | the i|
|00002b30| 6e 70 75 74 20 61 6e 64 | 20 6f 75 74 70 75 74 20 |nput and| output |
|00002b40| 66 69 6c 65 73 20 61 6e | 64 20 6f 62 74 61 69 6e |files an|d obtain|
|00002b50| 65 64 20 76 61 6c 75 65 | 73 20 66 6f 72 20 61 6c |ed value|s for al|
|00002b60| 6c 20 63 6f 6d 70 72 65 | 73 73 69 6f 6e 0a 58 20 |l compre|ssion.X |
|00002b70| 20 20 20 70 61 72 61 6d | 65 74 65 72 73 20 74 68 | param|eters th|
|00002b80| 61 74 20 61 72 65 6e 27 | 74 20 64 79 6e 61 6d 69 |at aren'|t dynami|
|00002b90| 63 61 6c 6c 79 20 64 65 | 74 65 72 6d 69 6e 65 64 |cally de|termined|
|00002ba0| 2e 20 20 6a 70 65 67 5f | 63 6f 6d 70 72 65 73 73 |. jpeg_|compress|
|00002bb0| 20 70 65 72 66 6f 72 6d | 73 0a 58 20 20 20 20 62 | perform|s.X b|
|00002bc0| 61 73 69 63 20 69 6e 69 | 74 69 61 6c 69 7a 61 74 |asic ini|tializat|
|00002bd0| 69 6f 6e 20 28 65 2e 67 | 2e 2c 20 63 61 6c 63 75 |ion (e.g|., calcu|
|00002be0| 6c 61 74 69 6e 67 20 74 | 68 65 20 73 69 7a 65 20 |lating t|he size |
|00002bf0| 6f 66 20 4d 43 55 73 29 | 2c 20 64 6f 65 73 20 74 |of MCUs)|, does t|
|00002c00| 68 65 0a 58 20 20 20 20 | 22 67 6c 6f 62 61 6c 22 |he.X |"global"|
|00002c10| 20 6d 65 74 68 6f 64 20 | 73 65 6c 65 63 74 69 6f | method |selectio|
|00002c20| 6e 20 70 61 73 73 2c 20 | 61 6e 64 20 66 69 6e 61 |n pass, |and fina|
|00002c30| 6c 6c 79 20 63 61 6c 6c | 73 20 74 68 65 20 73 65 |lly call|s the se|
|00002c40| 6c 65 63 74 65 64 20 70 | 69 70 65 6c 69 6e 65 0a |lected p|ipeline.|
|00002c50| 58 20 20 20 20 63 6f 6e | 74 72 6f 6c 20 6f 62 6a |X con|trol obj|
|00002c60| 65 63 74 2e 20 20 28 50 | 65 72 2d 73 63 61 6e 20 |ect. (P|er-scan |
|00002c70| 6d 65 74 68 6f 64 20 73 | 65 6c 65 63 74 69 6f 6e |method s|election|
|00002c80| 73 20 77 69 6c 6c 20 62 | 65 20 69 6e 76 6f 6b 65 |s will b|e invoke|
|00002c90| 64 20 62 79 20 74 68 65 | 0a 58 20 20 20 20 70 69 |d by the|.X pi|
|00002ca0| 70 65 6c 69 6e 65 20 63 | 6f 6e 74 72 6f 6c 6c 65 |peline c|ontrolle|
|00002cb0| 72 2e 29 0a 58 20 20 20 | 20 4e 6f 74 65 20 74 68 |r.).X | Note th|
|00002cc0| 61 74 20 6a 70 65 67 5f | 63 6f 6d 70 72 65 73 73 |at jpeg_|compress|
|00002cd0| 20 63 61 6e 27 74 20 62 | 65 20 61 20 6d 65 74 68 | can't b|e a meth|
|00002ce0| 6f 64 20 73 69 6e 63 65 | 20 69 74 20 69 73 20 69 |od since| it is i|
|00002cf0| 6e 76 6f 6b 65 64 20 70 | 72 69 6f 72 20 74 6f 0a |nvoked p|rior to.|
|00002d00| 58 20 20 20 20 6d 65 74 | 68 6f 64 20 73 65 6c 65 |X met|hod sele|
|00002d10| 63 74 69 6f 6e 2e 0a 58 | 0a 58 31 32 2e 20 55 73 |ction..X|.X12. Us|
|00002d20| 65 72 20 69 6e 74 65 72 | 66 61 63 65 3b 20 74 68 |er inter|face; th|
|00002d30| 69 73 20 69 73 20 74 68 | 65 20 61 72 63 68 69 74 |is is th|e archit|
|00002d40| 65 63 74 75 72 65 27 73 | 20 74 65 72 6d 20 66 6f |ecture's| term fo|
|00002d50| 72 20 22 74 68 65 20 72 | 65 73 74 20 6f 66 20 74 |r "the r|est of t|
|00002d60| 68 65 0a 58 20 20 20 20 | 61 70 70 6c 69 63 61 74 |he.X |applicat|
|00002d70| 69 6f 6e 20 70 72 6f 67 | 72 61 6d 22 2c 20 69 2e |ion prog|ram", i.|
|00002d80| 65 2e 2c 20 74 68 61 74 | 20 77 68 69 63 68 20 69 |e., that| which i|
|00002d90| 6e 76 6f 6b 65 73 20 74 | 68 65 20 4a 50 45 47 20 |nvokes t|he JPEG |
|00002da0| 63 6f 6d 70 72 65 73 73 | 6f 72 2e 20 20 49 6e 20 |compress|or. In |
|00002db0| 61 0a 58 20 20 20 20 73 | 74 61 6e 64 61 6c 6f 6e |a.X s|tandalon|
|00002dc0| 65 20 4a 50 45 47 20 63 | 6f 6d 70 72 65 73 73 69 |e JPEG c|ompressi|
|00002dd0| 6f 6e 20 70 72 6f 67 72 | 61 6d 20 74 68 65 20 55 |on progr|am the U|
|00002de0| 49 20 6e 65 65 64 20 62 | 65 20 6c 69 74 74 6c 65 |I need b|e little|
|00002df0| 20 6d 6f 72 65 20 74 68 | 61 6e 20 61 20 43 0a 58 | more th|an a C.X|
|00002e00| 20 20 20 20 6d 61 69 6e | 28 29 20 72 6f 75 74 69 | main|() routi|
|00002e10| 6e 65 20 61 6e 64 20 61 | 72 67 75 6d 65 6e 74 20 |ne and a|rgument |
|00002e20| 70 61 72 73 69 6e 67 20 | 63 6f 64 65 3b 20 62 75 |parsing |code; bu|
|00002e30| 74 20 77 65 20 63 61 6e | 20 65 78 70 65 63 74 20 |t we can| expect |
|00002e40| 74 68 61 74 20 74 68 65 | 20 4a 50 45 47 0a 58 20 |that the| JPEG.X |
|00002e50| 20 20 20 63 6f 6d 70 72 | 65 73 73 6f 72 20 6d 61 | compr|essor ma|
|00002e60| 79 20 62 65 20 69 6e 63 | 6f 72 70 6f 72 61 74 65 |y be inc|orporate|
|00002e70| 64 20 69 6e 74 6f 20 63 | 6f 6d 70 6c 65 78 20 67 |d into c|omplex g|
|00002e80| 72 61 70 68 69 63 73 20 | 61 70 70 6c 69 63 61 74 |raphics |applicat|
|00002e90| 69 6f 6e 73 2c 20 77 68 | 65 72 65 69 6e 0a 58 20 |ions, wh|erein.X |
|00002ea0| 20 20 20 74 68 65 20 55 | 49 20 69 73 20 6d 75 63 | the U|I is muc|
|00002eb0| 68 20 6d 6f 72 65 20 63 | 6f 6d 70 6c 65 78 2e 20 |h more c|omplex. |
|00002ec0| 20 4d 75 63 68 20 6f 66 | 20 74 68 65 20 55 49 20 | Much of| the UI |
|00002ed0| 77 69 6c 6c 20 6e 65 65 | 64 20 74 6f 20 62 65 20 |will nee|d to be |
|00002ee0| 77 72 69 74 74 65 6e 0a | 58 20 20 20 20 61 66 72 |written.|X afr|
|00002ef0| 65 73 68 20 66 6f 72 20 | 65 61 63 68 20 6e 6f 6e |esh for |each non|
|00002f00| 2d 55 6e 69 78 2d 6c 69 | 6b 65 20 70 6c 61 74 66 |-Unix-li|ke platf|
|00002f10| 6f 72 6d 20 74 68 65 20 | 63 6f 6d 70 72 65 73 73 |orm the |compress|
|00002f20| 6f 72 20 69 73 20 70 6f | 72 74 65 64 20 74 6f 2e |or is po|rted to.|
|00002f30| 0a 58 20 20 20 20 54 68 | 65 20 55 49 20 69 73 20 |.X Th|e UI is |
|00002f40| 65 78 70 65 63 74 65 64 | 20 74 6f 20 73 75 70 70 |expected| to supp|
|00002f50| 6c 79 20 69 6e 70 75 74 | 20 61 6e 64 20 6f 75 74 |ly input| and out|
|00002f60| 70 75 74 20 66 69 6c 65 | 73 20 61 6e 64 20 76 61 |put file|s and va|
|00002f70| 6c 75 65 73 20 66 6f 72 | 20 61 6c 6c 0a 58 20 20 |lues for| all.X |
|00002f80| 20 20 6e 6f 6e 2d 61 75 | 74 6f 6d 61 74 69 63 61 | non-au|tomatica|
|00002f90| 6c 6c 79 2d 63 68 6f 73 | 65 6e 20 63 6f 6d 70 72 |lly-chos|en compr|
|00002fa0| 65 73 73 69 6f 6e 20 70 | 61 72 61 6d 65 74 65 72 |ession p|arameter|
|00002fb0| 73 2e 20 20 28 48 65 6e | 63 65 20 64 65 66 61 75 |s. (Hen|ce defau|
|00002fc0| 6c 74 73 20 61 72 65 0a | 58 20 20 20 20 64 65 74 |lts are.|X det|
|00002fd0| 65 72 6d 69 6e 65 64 20 | 62 79 20 74 68 65 20 55 |ermined |by the U|
|00002fe0| 49 3b 20 77 65 20 73 68 | 6f 75 6c 64 20 70 72 6f |I; we sh|ould pro|
|00002ff0| 76 69 64 65 20 68 65 6c | 70 66 75 6c 20 72 6f 75 |vide hel|pful rou|
|00003000| 74 69 6e 65 73 20 74 6f | 20 66 69 6c 6c 20 69 6e |tines to| fill in|
|00003010| 0a 58 20 20 20 20 74 68 | 65 20 72 65 63 6f 6d 6d |.X th|e recomm|
|00003020| 65 6e 64 65 64 20 64 65 | 66 61 75 6c 74 73 2e 29 |ended de|faults.)|
|00003030| 20 20 54 68 65 20 55 49 | 20 6d 75 73 74 20 61 6c | The UI| must al|
|00003040| 73 6f 20 73 75 70 70 6c | 79 20 65 72 72 6f 72 20 |so suppl|y error |
|00003050| 68 61 6e 64 6c 69 6e 67 | 0a 58 20 20 20 20 72 6f |handling|.X ro|
|00003060| 75 74 69 6e 65 73 20 61 | 6e 64 20 73 6f 6d 65 20 |utines a|nd some |
|00003070| 6d 65 63 68 61 6e 69 73 | 6d 20 66 6f 72 20 74 72 |mechanis|m for tr|
|00003080| 61 63 65 20 6d 65 73 73 | 61 67 65 73 2e 0a 58 20 |ace mess|ages..X |
|00003090| 20 20 20 28 54 68 69 73 | 20 6d 6f 64 75 6c 65 20 | (This| module |
|000030a0| 68 69 64 65 73 20 74 68 | 65 20 75 73 65 72 20 69 |hides th|e user i|
|000030b0| 6e 74 65 72 66 61 63 65 | 20 70 72 6f 76 69 64 65 |nterface| provide|
|000030c0| 64 20 2d 2d 2d 20 63 6f | 6d 6d 61 6e 64 20 6c 69 |d --- co|mmand li|
|000030d0| 6e 65 2c 0a 58 20 20 20 | 20 69 6e 74 65 72 61 63 |ne,.X | interac|
|000030e0| 74 69 76 65 2c 20 65 74 | 63 2e 20 20 45 78 63 65 |tive, et|c. Exce|
|000030f0| 70 74 20 66 6f 72 20 65 | 72 72 6f 72 2f 6d 65 73 |pt for e|rror/mes|
|00003100| 73 61 67 65 20 68 61 6e | 64 6c 69 6e 67 2c 20 74 |sage han|dling, t|
|00003110| 68 65 20 55 49 20 63 61 | 6c 6c 73 20 74 68 65 0a |he UI ca|lls the.|
|00003120| 58 20 20 20 20 70 6f 72 | 74 61 62 6c 65 20 4a 50 |X por|table JP|
|00003130| 45 47 20 63 6f 64 65 2c | 20 6e 6f 74 20 74 68 65 |EG code,| not the|
|00003140| 20 6f 74 68 65 72 20 77 | 61 79 20 61 72 6f 75 6e | other w|ay aroun|
|00003150| 64 2e 29 0a 58 0a 58 31 | 33 2e 20 28 4f 70 74 69 |d.).X.X1|3. (Opti|
|00003160| 6f 6e 61 6c 29 20 43 6f | 6d 70 72 65 73 73 69 6f |onal) Co|mpressio|
|00003170| 6e 20 70 61 72 61 6d 65 | 74 65 72 20 73 65 6c 65 |n parame|ter sele|
|00003180| 63 74 69 6f 6e 20 63 6f | 6e 74 72 6f 6c 2e 0a 58 |ction co|ntrol..X|
|00003190| 09 65 6e 74 72 6f 70 79 | 5f 6f 70 74 69 6d 69 7a |.entropy|_optimiz|
|000031a0| 65 3a 20 67 69 76 65 6e | 20 61 6e 20 61 72 72 61 |e: given| an arra|
|000031b0| 79 20 6f 66 20 4d 43 55 | 73 20 72 65 61 64 79 20 |y of MCU|s ready |
|000031c0| 74 6f 20 62 65 20 66 65 | 64 20 74 6f 20 65 6e 74 |to be fe|d to ent|
|000031d0| 72 6f 70 79 0a 58 09 09 | 09 20 20 65 6e 63 6f 64 |ropy.X..|. encod|
|000031e0| 69 6e 67 2c 20 66 69 6e | 64 20 6f 70 74 69 6d 61 |ing, fin|d optima|
|000031f0| 6c 20 65 6e 63 6f 64 69 | 6e 67 20 70 61 72 61 6d |l encodi|ng param|
|00003200| 65 74 65 72 73 2e 0a 58 | 20 20 20 20 54 68 65 20 |eters..X| The |
|00003210| 61 63 74 75 61 6c 20 6f | 70 74 69 6d 69 7a 61 74 |actual o|ptimizat|
|00003220| 69 6f 6e 20 61 6c 67 6f | 72 69 74 68 6d 20 6f 75 |ion algo|rithm ou|
|00003230| 67 68 74 20 74 6f 20 62 | 65 20 73 65 70 61 72 61 |ght to b|e separa|
|00003240| 74 65 64 20 6f 75 74 20 | 61 73 20 61 6e 20 6f 62 |ted out |as an ob|
|00003250| 6a 65 63 74 2c 0a 58 20 | 20 20 20 65 76 65 6e 20 |ject,.X | even |
|00003260| 74 68 6f 75 67 68 20 61 | 20 73 70 65 63 69 61 6c |though a| special|
|00003270| 20 70 69 70 65 6c 69 6e | 65 20 63 6f 6e 74 72 6f | pipelin|e contro|
|00003280| 6c 20 6d 65 74 68 6f 64 | 20 77 69 6c 6c 20 62 65 |l method| will be|
|00003290| 20 6e 65 65 64 65 64 2e | 20 20 28 54 68 65 0a 58 | needed.| (The.X|
|000032a0| 20 20 20 20 70 69 70 65 | 6c 69 6e 65 20 63 6f 6e | pipe|line con|
|000032b0| 74 72 6f 6c 6c 65 72 20 | 6f 6e 6c 79 20 68 61 73 |troller |only has|
|000032c0| 20 74 6f 20 75 6e 64 65 | 72 73 74 61 6e 64 20 74 | to unde|rstand t|
|000032d0| 68 61 74 20 74 68 65 20 | 6f 75 74 70 75 74 20 6f |hat the |output o|
|000032e0| 66 20 65 78 74 72 61 63 | 74 5f 4d 43 55 73 0a 58 |f extrac|t_MCUs.X|
|000032f0| 20 20 20 20 6d 75 73 74 | 20 62 65 20 62 75 69 6c | must| be buil|
|00003300| 74 20 75 70 20 61 73 20 | 61 20 76 69 72 74 75 61 |t up as |a virtua|
|00003310| 6c 20 61 72 72 61 79 20 | 72 61 74 68 65 72 20 74 |l array |rather t|
|00003320| 68 61 6e 20 66 65 64 20 | 64 69 72 65 63 74 6c 79 |han fed |directly|
|00003330| 20 74 6f 20 65 6e 74 72 | 6f 70 79 0a 58 20 20 20 | to entr|opy.X |
|00003340| 20 65 6e 63 6f 64 69 6e | 67 20 61 6e 64 20 6f 75 | encodin|g and ou|
|00003350| 74 70 75 74 2e 20 20 54 | 68 69 73 20 70 69 70 65 |tput. T|his pipe|
|00003360| 6c 69 6e 65 20 62 65 68 | 61 76 69 6f 72 20 6d 61 |line beh|avior ma|
|00003370| 79 20 61 6c 73 6f 20 62 | 65 20 75 73 65 66 75 6c |y also b|e useful|
|00003380| 20 66 6f 72 20 66 75 74 | 75 72 65 0a 58 20 20 20 | for fut|ure.X |
|00003390| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 20 | impleme|ntation |
|000033a0| 6f 66 20 68 69 65 72 61 | 72 63 68 69 63 61 6c 20 |of hiera|rchical |
|000033b0| 6d 6f 64 65 73 2c 20 65 | 74 63 2e 29 0a 58 20 20 |modes, e|tc.).X |
|000033c0| 20 20 54 6f 20 6d 69 6e | 69 6d 69 7a 65 20 74 68 | To min|imize th|
|000033d0| 65 20 61 6d 6f 75 6e 74 | 20 6f 66 20 63 6f 6e 74 |e amount| of cont|
|000033e0| 72 6f 6c 20 6c 6f 67 69 | 63 20 69 6e 20 74 68 65 |rol logi|c in the|
|000033f0| 20 6f 70 74 69 6d 69 7a | 61 74 69 6f 6e 20 6d 6f | optimiz|ation mo|
|00003400| 64 75 6c 65 2c 20 74 68 | 65 0a 58 20 20 20 20 70 |dule, th|e.X p|
|00003410| 69 70 65 6c 69 6e 65 20 | 63 6f 6e 74 72 6f 6c 20 |ipeline |control |
|00003420| 64 6f 65 73 6e 27 74 20 | 61 63 74 75 61 6c 6c 79 |doesn't |actually|
|00003430| 20 68 61 6e 64 20 6f 76 | 65 72 20 62 69 67 2d 61 | hand ov|er big-a|
|00003440| 72 72 61 79 20 70 6f 69 | 6e 74 65 72 73 2c 20 62 |rray poi|nters, b|
|00003450| 75 74 20 72 61 74 68 65 | 72 0a 58 20 20 20 20 61 |ut rathe|r.X a|
|00003460| 6e 20 22 69 74 65 72 61 | 74 6f 72 22 3a 20 61 20 |n "itera|tor": a |
|00003470| 66 75 6e 63 74 69 6f 6e | 20 77 68 69 63 68 20 6b |function| which k|
|00003480| 6e 6f 77 73 20 68 6f 77 | 20 74 6f 20 73 63 61 6e |nows how| to scan|
|00003490| 20 74 68 65 20 73 74 6f | 72 65 64 20 69 6d 61 67 | the sto|red imag|
|000034a0| 65 2e 0a 58 20 20 20 20 | 28 54 68 69 73 20 68 69 |e..X |(This hi|
|000034b0| 64 65 73 20 74 68 65 20 | 64 65 74 61 69 6c 73 20 |des the |details |
|000034c0| 6f 66 20 74 68 65 20 70 | 61 72 61 6d 65 74 65 72 |of the p|arameter|
|000034d0| 20 6f 70 74 69 6d 69 7a | 61 74 69 6f 6e 20 61 6c | optimiz|ation al|
|000034e0| 67 6f 72 69 74 68 6d 2e | 29 0a 58 0a 58 20 20 20 |gorithm.|).X.X |
|000034f0| 20 54 68 65 20 70 72 65 | 73 65 6e 74 20 64 65 73 | The pre|sent des|
|00003500| 69 67 6e 20 64 6f 65 73 | 6e 27 74 20 61 6c 6c 6f |ign does|n't allo|
|00003510| 77 20 66 6f 72 20 6d 75 | 6c 74 69 70 6c 65 20 70 |w for mu|ltiple p|
|00003520| 61 73 73 65 73 20 61 74 | 20 65 61 72 6c 69 65 72 |asses at| earlier|
|00003530| 20 70 6f 69 6e 74 73 0a | 58 20 20 20 20 69 6e 20 | points.|X in |
|00003540| 74 68 65 20 70 69 70 65 | 6c 69 6e 65 2c 20 62 75 |the pipe|line, bu|
|00003550| 74 20 61 6c 6c 6f 77 69 | 6e 67 20 74 68 61 74 20 |t allowi|ng that |
|00003560| 77 6f 75 6c 64 20 6f 6e | 6c 79 20 72 65 71 75 69 |would on|ly requi|
|00003570| 72 65 20 70 72 6f 76 69 | 64 69 6e 67 20 73 6f 6d |re provi|ding som|
|00003580| 65 0a 58 20 20 20 20 6e | 65 77 20 70 69 70 65 6c |e.X n|ew pipel|
|00003590| 69 6e 65 20 63 6f 6e 74 | 72 6f 6c 20 6d 65 74 68 |ine cont|rol meth|
|000035a0| 6f 64 73 3b 20 6e 6f 74 | 68 69 6e 67 20 65 6c 73 |ods; not|hing els|
|000035b0| 65 20 6e 65 65 64 20 63 | 68 61 6e 67 65 2e 0a 58 |e need c|hange..X|
|000035c0| 0a 58 31 34 2e 20 41 20 | 6d 65 6d 6f 72 79 20 6d |.X14. A |memory m|
|000035d0| 61 6e 61 67 65 6d 65 6e | 74 20 6f 62 6a 65 63 74 |anagemen|t object|
|000035e0| 2e 20 20 54 68 69 73 20 | 77 69 6c 6c 20 70 72 6f |. This |will pro|
|000035f0| 76 69 64 65 20 6d 65 74 | 68 6f 64 73 20 74 6f 20 |vide met|hods to |
|00003600| 61 6c 6c 6f 63 61 74 65 | 20 22 73 6d 61 6c 6c 22 |allocate| "small"|
|00003610| 0a 58 20 20 20 20 74 68 | 69 6e 67 73 20 61 6e 64 |.X th|ings and|
|00003620| 20 22 62 69 67 22 20 74 | 68 69 6e 67 73 2e 20 20 | "big" t|hings. |
|00003630| 53 6d 61 6c 6c 20 74 68 | 69 6e 67 73 20 68 61 76 |Small th|ings hav|
|00003640| 65 20 74 6f 20 66 69 74 | 20 69 6e 20 6d 65 6d 6f |e to fit| in memo|
|00003650| 72 79 20 61 6e 64 20 79 | 6f 75 20 67 65 74 0a 58 |ry and y|ou get.X|
|00003660| 20 20 20 20 62 61 63 6b | 20 64 69 72 65 63 74 20 | back| direct |
|00003670| 70 6f 69 6e 74 65 72 73 | 20 28 74 68 69 73 20 63 |pointers| (this c|
|00003680| 6f 75 6c 64 20 62 65 20 | 68 61 6e 64 6c 65 64 20 |ould be |handled |
|00003690| 62 79 20 64 69 72 65 63 | 74 20 63 61 6c 6c 73 20 |by direc|t calls |
|000036a0| 74 6f 20 6d 61 6c 6c 6f | 63 2c 20 62 75 74 0a 58 |to mallo|c, but.X|
|000036b0| 20 20 20 20 69 74 27 73 | 20 63 6c 65 61 6e 65 72 | it's| cleaner|
|000036c0| 20 6e 6f 74 20 74 6f 20 | 61 73 73 75 6d 65 20 6d | not to |assume m|
|000036d0| 61 6c 6c 6f 63 20 69 73 | 20 74 68 65 20 72 69 67 |alloc is| the rig|
|000036e0| 68 74 20 72 6f 75 74 69 | 6e 65 29 2e 20 20 22 42 |ht routi|ne). "B|
|000036f0| 69 67 22 20 74 68 69 6e | 67 73 0a 58 20 20 20 20 |ig" thin|gs.X |
|00003700| 6d 65 61 6e 20 62 75 66 | 66 65 72 65 64 20 69 6d |mean buf|fered im|
|00003710| 61 67 65 73 20 66 6f 72 | 20 6d 75 6c 74 69 70 6c |ages for| multipl|
|00003720| 65 20 70 61 73 73 65 73 | 2c 20 6e 6f 6e 69 6e 74 |e passes|, nonint|
|00003730| 65 72 6c 65 61 76 65 64 | 20 6f 75 74 70 75 74 2c |erleaved| output,|
|00003740| 20 65 74 63 2e 0a 58 20 | 20 20 20 49 6e 20 74 68 | etc..X | In th|
|00003750| 69 73 20 63 61 73 65 20 | 74 68 65 20 6d 65 6d 6f |is case |the memo|
|00003760| 72 79 20 6d 61 6e 61 67 | 65 6d 65 6e 74 20 6f 62 |ry manag|ement ob|
|00003770| 6a 65 63 74 20 77 69 6c | 6c 20 67 69 76 65 20 79 |ject wil|l give y|
|00003780| 6f 75 20 72 6f 6f 6d 20 | 66 6f 72 20 61 20 66 65 |ou room |for a fe|
|00003790| 77 20 4d 43 55 0a 58 20 | 20 20 20 72 6f 77 73 20 |w MCU.X | rows |
|000037a0| 61 6e 64 20 79 6f 75 20 | 68 61 76 65 20 74 6f 20 |and you |have to |
|000037b0| 61 73 6b 20 66 6f 72 20 | 61 63 63 65 73 73 20 74 |ask for |access t|
|000037c0| 6f 20 74 68 65 20 6e 65 | 78 74 20 66 65 77 3b 20 |o the ne|xt few; |
|000037d0| 64 75 6d 70 69 6e 67 20 | 61 6e 64 20 72 65 6c 6f |dumping |and relo|
|000037e0| 61 64 69 6e 67 0a 58 20 | 20 20 20 69 6e 20 61 20 |ading.X | in a |
|000037f0| 74 65 6d 70 6f 72 61 72 | 79 20 66 69 6c 65 20 77 |temporar|y file w|
|00003800| 69 6c 6c 20 67 6f 20 6f | 6e 20 62 65 68 69 6e 64 |ill go o|n behind|
|00003810| 20 74 68 65 20 73 63 65 | 6e 65 73 2e 20 20 28 41 | the sce|nes. (A|
|00003820| 6c 6c 20 62 69 67 20 6f | 62 6a 65 63 74 73 20 61 |ll big o|bjects a|
|00003830| 72 65 0a 58 20 20 20 20 | 69 6d 61 67 65 20 61 72 |re.X |image ar|
|00003840| 72 61 79 73 20 63 6f 6e | 74 61 69 6e 69 6e 67 20 |rays con|taining |
|00003850| 65 69 74 68 65 72 20 73 | 61 6d 70 6c 65 73 20 6f |either s|amples o|
|00003860| 72 20 63 6f 65 66 66 69 | 63 69 65 6e 74 73 2c 20 |r coeffi|cients, |
|00003870| 61 6e 64 20 77 69 6c 6c | 20 62 65 0a 58 20 20 20 |and will| be.X |
|00003880| 20 73 63 61 6e 6e 65 64 | 20 74 6f 70 2d 74 6f 2d | scanned| top-to-|
|00003890| 62 6f 74 74 6f 6d 20 73 | 6f 6d 65 20 6e 75 6d 62 |bottom s|ome numb|
|000038a0| 65 72 20 6f 66 20 74 69 | 6d 65 73 2c 20 73 6f 20 |er of ti|mes, so |
|000038b0| 77 65 20 63 61 6e 20 61 | 70 70 6c 79 20 74 68 69 |we can a|pply thi|
|000038c0| 73 20 61 63 63 65 73 73 | 0a 58 20 20 20 20 6d 6f |s access|.X mo|
|000038d0| 64 65 6c 20 65 61 73 69 | 6c 79 2e 29 20 20 4f 6e |del easi|ly.) On|
|000038e0| 20 61 20 70 6c 61 74 66 | 6f 72 6d 20 77 69 74 68 | a platf|orm with|
|000038f0| 20 76 69 72 74 75 61 6c | 20 6d 65 6d 6f 72 79 2c | virtual| memory,|
|00003900| 20 74 68 65 20 6d 65 6d | 6f 72 79 20 6d 61 6e 61 | the mem|ory mana|
|00003910| 67 65 72 20 63 61 6e 0a | 58 20 20 20 20 74 72 65 |ger can.|X tre|
|00003920| 61 74 20 73 6d 61 6c 6c | 20 61 6e 64 20 62 69 67 |at small| and big|
|00003930| 20 74 68 69 6e 67 73 20 | 61 6c 69 6b 65 3a 20 6a | things |alike: j|
|00003940| 75 73 74 20 6d 61 6c 6c | 6f 63 20 75 70 20 65 6e |ust mall|oc up en|
|00003950| 6f 75 67 68 20 76 69 72 | 74 75 61 6c 20 6d 65 6d |ough vir|tual mem|
|00003960| 6f 72 79 20 66 6f 72 0a | 58 20 20 20 20 74 68 65 |ory for.|X the|
|00003970| 20 77 68 6f 6c 65 20 69 | 6d 61 67 65 2c 20 61 6e | whole i|mage, an|
|00003980| 64 20 6c 65 74 20 74 68 | 65 20 6f 70 65 72 61 74 |d let th|e operat|
|00003990| 69 6e 67 20 73 79 73 74 | 65 6d 20 77 6f 72 72 79 |ing syst|em worry|
|000039a0| 20 61 62 6f 75 74 20 73 | 77 61 70 70 69 6e 67 20 | about s|wapping |
|000039b0| 74 68 65 0a 58 20 20 20 | 20 69 6d 61 67 65 20 74 |the.X | image t|
|000039c0| 6f 20 64 69 73 6b 2e 0a | 58 0a 58 20 20 20 20 4d |o disk..|X.X M|
|000039d0| 6f 73 74 20 6f 66 20 74 | 68 65 20 61 63 74 75 61 |ost of t|he actua|
|000039e0| 6c 20 63 61 6c 6c 73 20 | 6f 6e 20 74 68 65 20 6d |l calls |on the m|
|000039f0| 65 6d 6f 72 79 20 6d 61 | 6e 61 67 65 72 20 77 69 |emory ma|nager wi|
|00003a00| 6c 6c 20 62 65 20 6d 61 | 64 65 20 66 72 6f 6d 20 |ll be ma|de from |
|00003a10| 70 69 70 65 6c 69 6e 65 | 0a 58 20 20 20 20 63 6f |pipeline|.X co|
|00003a20| 6e 74 72 6f 6c 20 6f 62 | 6a 65 63 74 73 3b 20 63 |ntrol ob|jects; c|
|00003a30| 68 61 6e 67 69 6e 67 20 | 61 6e 79 20 64 61 74 61 |hanging |any data|
|00003a40| 20 69 74 65 6d 20 66 72 | 6f 6d 20 22 73 6d 61 6c | item fr|om "smal|
|00003a50| 6c 22 20 74 6f 20 22 62 | 69 67 22 20 73 74 61 74 |l" to "b|ig" stat|
|00003a60| 75 73 20 77 6f 75 6c 64 | 0a 58 20 20 20 20 72 65 |us would|.X re|
|00003a70| 71 75 69 72 65 20 61 20 | 6e 65 77 20 70 69 70 65 |quire a |new pipe|
|00003a80| 6c 69 6e 65 20 63 6f 6e | 74 72 6f 6c 20 6f 62 6a |line con|trol obj|
|00003a90| 65 63 74 2c 20 73 69 6e | 63 65 20 69 74 20 77 69 |ect, sin|ce it wi|
|00003aa0| 6c 6c 20 63 6f 6e 74 61 | 69 6e 20 74 68 65 20 6c |ll conta|in the l|
|00003ab0| 6f 67 69 63 20 74 6f 0a | 58 20 20 20 20 61 73 6b |ogic to.|X ask|
|00003ac0| 20 66 6f 72 20 61 20 6e | 65 77 20 63 68 75 6e 6b | for a n|ew chunk|
|00003ad0| 20 6f 66 20 61 20 62 69 | 67 20 74 68 69 6e 67 2e | of a bi|g thing.|
|00003ae0| 20 20 54 68 75 73 2c 20 | 6f 6e 65 20 77 61 79 20 | Thus, |one way |
|00003af0| 69 6e 20 77 68 69 63 68 | 20 70 69 70 65 6c 69 6e |in which| pipelin|
|00003b00| 65 0a 58 20 20 20 20 63 | 6f 6e 74 72 6f 6c 6c 65 |e.X c|ontrolle|
|00003b10| 72 73 20 77 69 6c 6c 20 | 76 61 72 79 20 69 73 20 |rs will |vary is |
|00003b20| 69 6e 20 77 68 69 63 68 | 20 73 74 72 75 63 74 75 |in which| structu|
|00003b30| 72 65 73 20 74 68 65 79 | 20 74 72 65 61 74 20 61 |res they| treat a|
|00003b40| 73 20 62 69 67 2e 0a 58 | 0a 58 20 20 20 20 54 68 |s big..X|.X Th|
|00003b50| 65 20 6d 65 6d 6f 72 79 | 20 6d 61 6e 61 67 65 72 |e memory| manager|
|00003b60| 20 77 69 6c 6c 20 6e 65 | 65 64 20 74 6f 20 62 65 | will ne|ed to be|
|00003b70| 20 74 6f 6c 64 20 72 6f | 75 67 68 6c 79 20 68 6f | told ro|ughly ho|
|00003b80| 77 20 6d 75 63 68 20 73 | 70 61 63 65 20 69 73 20 |w much s|pace is |
|00003b90| 67 6f 69 6e 67 20 74 6f | 0a 58 20 20 20 20 62 65 |going to|.X be|
|00003ba0| 20 72 65 71 75 65 73 74 | 65 64 20 6f 76 65 72 61 | request|ed overa|
|00003bb0| 6c 6c 2c 20 73 6f 20 74 | 68 61 74 20 69 74 20 63 |ll, so t|hat it c|
|00003bc0| 61 6e 20 66 69 67 75 72 | 65 20 6f 75 74 20 68 6f |an figur|e out ho|
|00003bd0| 77 20 62 69 67 20 61 20 | 62 75 66 66 65 72 20 69 |w big a |buffer i|
|00003be0| 73 20 73 61 66 65 0a 58 | 20 20 20 20 74 6f 20 61 |s safe.X| to a|
|00003bf0| 6c 6c 6f 63 61 74 65 20 | 66 6f 72 20 61 20 22 62 |llocate |for a "b|
|00003c00| 69 67 22 20 6f 62 6a 65 | 63 74 2e 20 20 28 49 66 |ig" obje|ct. (If|
|00003c10| 20 69 74 20 68 61 70 70 | 65 6e 73 20 74 68 61 74 | it happ|ens that|
|00003c20| 20 79 6f 75 20 61 72 65 | 20 64 65 61 6c 69 6e 67 | you are| dealing|
|00003c30| 20 77 69 74 68 0a 58 20 | 20 20 20 61 20 73 6d 61 | with.X | a sma|
|00003c40| 6c 6c 20 69 6d 61 67 65 | 2c 20 79 6f 75 27 64 20 |ll image|, you'd |
|00003c50| 6c 69 6b 65 20 74 6f 20 | 64 65 63 69 64 65 20 74 |like to |decide t|
|00003c60| 6f 20 6b 65 65 70 20 69 | 74 20 61 6c 6c 20 69 6e |o keep i|t all in|
|00003c70| 20 6d 65 6d 6f 72 79 21 | 29 20 20 54 68 65 20 6d | memory!|) The m|
|00003c80| 6f 73 74 0a 58 20 20 20 | 20 66 6c 65 78 69 62 6c |ost.X | flexibl|
|00003c90| 65 20 77 61 79 20 6f 66 | 20 64 6f 69 6e 67 20 74 |e way of| doing t|
|00003ca0| 68 69 73 20 69 73 20 74 | 6f 20 64 69 76 69 64 65 |his is t|o divide|
|00003cb0| 20 61 6c 6c 6f 63 61 74 | 69 6f 6e 20 6f 66 20 22 | allocat|ion of "|
|00003cc0| 62 69 67 22 20 6f 62 6a | 65 63 74 73 20 69 6e 74 |big" obj|ects int|
|00003cd0| 6f 0a 58 20 20 20 20 74 | 77 6f 20 73 74 65 70 73 |o.X t|wo steps|
|00003ce0| 2e 20 20 46 69 72 73 74 | 2c 20 74 68 65 72 65 20 |. First|, there |
|00003cf0| 77 69 6c 6c 20 62 65 20 | 6f 6e 65 20 6f 72 20 6d |will be |one or m|
|00003d00| 6f 72 65 20 22 72 65 71 | 75 65 73 74 22 20 63 61 |ore "req|uest" ca|
|00003d10| 6c 6c 73 20 74 68 61 74 | 20 69 6e 64 69 63 61 74 |lls that| indicat|
|00003d20| 65 0a 58 20 20 20 20 74 | 68 65 20 64 65 73 69 72 |e.X t|he desir|
|00003d30| 65 64 20 6f 62 6a 65 63 | 74 20 73 69 7a 65 73 3b |ed objec|t sizes;|
|00003d40| 20 74 68 65 6e 20 61 6e | 20 22 69 6e 73 74 61 6e | then an| "instan|
|00003d50| 74 69 61 74 65 22 20 63 | 61 6c 6c 20 63 61 75 73 |tiate" c|all caus|
|00003d60| 65 73 20 74 68 65 20 6d | 65 6d 6f 72 79 0a 58 20 |es the m|emory.X |
|00003d70| 20 20 20 6d 61 6e 61 67 | 65 72 20 74 6f 20 61 63 | manag|er to ac|
|00003d80| 74 75 61 6c 6c 79 20 63 | 6f 6e 73 74 72 75 63 74 |tually c|onstruct|
|00003d90| 20 74 68 65 20 6f 62 6a | 65 63 74 73 2e 20 20 54 | the obj|ects. T|
|00003da0| 68 65 20 69 6e 73 74 61 | 6e 74 69 61 74 69 6f 6e |he insta|ntiation|
|00003db0| 20 6d 75 73 74 20 6f 63 | 63 75 72 0a 58 20 20 20 | must oc|cur.X |
|00003dc0| 20 62 65 66 6f 72 65 20 | 74 68 65 20 63 6f 6e 74 | before |the cont|
|00003dd0| 65 6e 74 73 20 6f 66 20 | 61 6e 79 20 62 69 67 20 |ents of |any big |
|00003de0| 6f 62 6a 65 63 74 20 63 | 61 6e 20 62 65 20 61 63 |object c|an be ac|
|00003df0| 63 65 73 73 65 64 2e 0a | 58 0a 58 20 20 20 20 46 |cessed..|X.X F|
|00003e00| 6f 72 20 38 30 78 38 36 | 20 43 50 55 73 2c 20 77 |or 80x86| CPUs, w|
|00003e10| 65 20 77 6f 75 6c 64 20 | 6c 69 6b 65 20 74 68 65 |e would |like the|
|00003e20| 20 63 6f 64 65 20 74 6f | 20 62 65 20 63 6f 6d 70 | code to| be comp|
|00003e30| 69 6c 61 62 6c 65 20 75 | 6e 64 65 72 20 73 6d 61 |ilable u|nder sma|
|00003e40| 6c 6c 20 6f 72 0a 58 20 | 20 20 20 6d 65 64 69 75 |ll or.X | mediu|
|00003e50| 6d 20 6d 6f 64 65 6c 2c | 20 6d 65 61 6e 69 6e 67 |m model,| meaning|
|00003e60| 20 74 68 61 74 20 70 6f | 69 6e 74 65 72 73 20 61 | that po|inters a|
|00003e70| 72 65 20 31 36 20 62 69 | 74 73 20 75 6e 6c 65 73 |re 16 bi|ts unles|
|00003e80| 73 20 65 78 70 6c 69 63 | 69 74 6c 79 20 64 65 63 |s explic|itly dec|
|00003e90| 6c 61 72 65 64 0a 58 20 | 20 20 20 46 41 52 2e 20 |lared.X | FAR. |
|00003ea0| 20 48 65 6e 63 65 20 73 | 70 61 63 65 20 61 6c 6c | Hence s|pace all|
|00003eb0| 6f 63 61 74 65 64 20 62 | 79 20 74 68 65 20 22 73 |ocated b|y the "s|
|00003ec0| 6d 61 6c 6c 22 20 61 6c | 6c 6f 63 61 74 6f 72 20 |mall" al|locator |
|00003ed0| 6d 75 73 74 20 66 69 74 | 20 69 6e 74 6f 20 74 68 |must fit| into th|
|00003ee0| 65 0a 58 20 20 20 20 36 | 34 4b 62 20 64 65 66 61 |e.X 6|4Kb defa|
|00003ef0| 75 6c 74 20 64 61 74 61 | 20 73 65 67 6d 65 6e 74 |ult data| segment|
|00003f00| 2c 20 61 6c 6f 6e 67 20 | 77 69 74 68 20 73 74 61 |, along |with sta|
|00003f10| 63 6b 20 73 70 61 63 65 | 20 61 6e 64 20 67 6c 6f |ck space| and glo|
|00003f20| 62 61 6c 2f 73 74 61 74 | 69 63 20 64 61 74 61 2e |bal/stat|ic data.|
|00003f30| 0a 58 20 20 20 20 46 6f | 72 20 6e 6f 72 6d 61 6c |.X Fo|r normal|
|00003f40| 20 4a 50 45 47 20 6f 70 | 65 72 61 74 69 6f 6e 73 | JPEG op|erations|
|00003f50| 20 77 65 20 73 65 65 6d | 20 74 6f 20 6e 65 65 64 | we seem| to need|
|00003f60| 20 6f 6e 6c 79 20 61 62 | 6f 75 74 20 33 32 4b 62 | only ab|out 32Kb|
|00003f70| 20 6f 66 20 73 75 63 68 | 20 73 70 61 63 65 2c 0a | of such| space,.|
|00003f80| 58 20 20 20 20 73 6f 20 | 77 65 20 61 72 65 20 77 |X so |we are w|
|00003f90| 69 74 68 69 6e 20 74 68 | 65 20 74 61 72 67 65 74 |ithin th|e target|
|00003fa0| 20 28 61 6e 64 20 68 61 | 76 65 20 61 20 72 65 61 | (and ha|ve a rea|
|00003fb0| 73 6f 6e 61 62 6c 65 20 | 73 6c 6f 70 20 66 6f 72 |sonable |slop for|
|00003fc0| 20 74 68 65 20 6e 65 65 | 64 73 20 6f 66 0a 58 20 | the nee|ds of.X |
|00003fd0| 20 20 20 61 20 73 75 72 | 72 6f 75 6e 64 69 6e 67 | a sur|rounding|
|00003fe0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 70 72 6f | applica|tion pro|
|00003ff0| 67 72 61 6d 29 2e 20 20 | 48 6f 77 65 76 65 72 2c |gram). |However,|
|00004000| 20 73 6f 6d 65 20 63 6f | 6c 6f 72 20 71 75 61 6e | some co|lor quan|
|00004010| 74 69 7a 61 74 69 6f 6e | 0a 58 20 20 20 20 61 6c |tization|.X al|
|00004020| 67 6f 72 69 74 68 6d 73 | 20 6e 65 65 64 20 36 34 |gorithms| need 64|
|00004030| 4b 62 20 6f 72 20 6d 6f | 72 65 20 6f 66 20 61 6c |Kb or mo|re of al|
|00004040| 6c 2d 69 6e 2d 6d 65 6d | 6f 72 79 20 73 70 61 63 |l-in-mem|ory spac|
|00004050| 65 20 69 6e 20 6f 72 64 | 65 72 20 74 6f 20 63 72 |e in ord|er to cr|
|00004060| 65 61 74 65 0a 58 20 20 | 20 20 63 6f 6c 6f 72 20 |eate.X | color |
|00004070| 68 69 73 74 6f 67 72 61 | 6d 73 2e 20 20 46 6f 72 |histogra|ms. For|
|00004080| 20 74 68 69 73 20 70 75 | 72 70 6f 73 65 2c 20 77 | this pu|rpose, w|
|00004090| 65 20 77 69 6c 6c 20 61 | 6c 73 6f 20 73 75 70 70 |e will a|lso supp|
|000040a0| 6f 72 74 20 22 6d 65 64 | 69 75 6d 22 20 73 69 7a |ort "med|ium" siz|
|000040b0| 65 0a 58 20 20 20 20 74 | 68 69 6e 67 73 2e 20 20 |e.X t|hings. |
|000040c0| 54 68 65 73 65 20 61 72 | 65 20 73 65 6d 61 6e 74 |These ar|e semant|
|000040d0| 69 63 61 6c 6c 79 20 74 | 68 65 20 73 61 6d 65 20 |ically t|he same |
|000040e0| 61 73 20 22 73 6d 61 6c | 6c 22 20 74 68 69 6e 67 |as "smal|l" thing|
|000040f0| 73 20 62 75 74 20 61 72 | 65 0a 58 20 20 20 20 72 |s but ar|e.X r|
|00004100| 65 66 65 72 65 6e 63 65 | 64 20 74 68 72 6f 75 67 |eference|d throug|
|00004110| 68 20 46 41 52 20 70 6f | 69 6e 74 65 72 73 2e 0a |h FAR po|inters..|
|00004120| 58 0a 58 20 20 20 20 54 | 68 65 20 66 6f 6c 6c 6f |X.X T|he follo|
|00004130| 77 69 6e 67 20 6d 65 74 | 68 6f 64 73 20 77 69 6c |wing met|hods wil|
|00004140| 6c 20 62 65 20 6e 65 65 | 64 65 64 3a 0a 58 09 61 |l be nee|ded:.X.a|
|00004150| 6c 6c 6f 63 5f 73 6d 61 | 6c 6c 3a 09 61 6c 6c 6f |lloc_sma|ll:.allo|
|00004160| 63 61 74 65 20 61 6e 20 | 6f 62 6a 65 63 74 20 6f |cate an |object o|
|00004170| 66 20 67 69 76 65 6e 20 | 73 69 7a 65 3b 20 75 73 |f given |size; us|
|00004180| 65 20 66 6f 72 20 61 6e | 79 20 72 61 6e 64 6f 6d |e for an|y random|
|00004190| 0a 58 09 09 09 64 61 74 | 61 20 74 68 61 74 27 73 |.X...dat|a that's|
|000041a0| 20 6e 6f 74 20 61 6e 20 | 69 6d 61 67 65 20 61 72 | not an |image ar|
|000041b0| 72 61 79 2e 0a 58 09 66 | 72 65 65 5f 73 6d 61 6c |ray..X.f|ree_smal|
|000041c0| 6c 3a 09 72 65 6c 65 61 | 73 65 20 73 61 6d 65 2e |l:.relea|se same.|
|000041d0| 0a 58 09 61 6c 6c 6f 63 | 5f 6d 65 64 69 75 6d 3a |.X.alloc|_medium:|
|000041e0| 09 6c 69 6b 65 20 61 6c | 6c 6f 63 5f 73 6d 61 6c |.like al|loc_smal|
|000041f0| 6c 2c 20 62 75 74 20 72 | 65 74 75 72 6e 73 20 61 |l, but r|eturns a|
|00004200| 20 46 41 52 20 70 6f 69 | 6e 74 65 72 2e 20 20 55 | FAR poi|nter. U|
|00004210| 73 65 20 66 6f 72 0a 58 | 09 09 09 61 6e 79 20 6f |se for.X|...any o|
|00004220| 62 6a 65 63 74 20 62 69 | 67 67 65 72 20 74 68 61 |bject bi|gger tha|
|00004230| 6e 20 61 20 63 6f 75 70 | 6c 65 20 6b 69 6c 6f 62 |n a coup|le kilob|
|00004240| 79 74 65 73 2e 0a 58 09 | 66 72 65 65 5f 6d 65 64 |ytes..X.|free_med|
|00004250| 69 75 6d 3a 09 72 65 6c | 65 61 73 65 20 73 61 6d |ium:.rel|ease sam|
|00004260| 65 2e 0a 58 09 61 6c 6c | 6f 63 5f 73 6d 61 6c 6c |e..X.all|oc_small|
|00004270| 5f 73 61 72 72 61 79 3a | 20 63 6f 6e 73 74 72 75 |_sarray:| constru|
|00004280| 63 74 20 61 6e 20 61 6c | 6c 2d 69 6e 2d 6d 65 6d |ct an al|l-in-mem|
|00004290| 6f 72 79 20 69 6d 61 67 | 65 20 73 61 6d 70 6c 65 |ory imag|e sample|
|000042a0| 20 61 72 72 61 79 2e 0a | 58 09 66 72 65 65 5f 73 | array..|X.free_s|
|000042b0| 6d 61 6c 6c 5f 73 61 72 | 72 61 79 3a 20 20 72 65 |mall_sar|ray: re|
|000042c0| 6c 65 61 73 65 20 73 61 | 6d 65 2e 0a 58 09 61 6c |lease sa|me..X.al|
|000042d0| 6c 6f 63 5f 73 6d 61 6c | 6c 5f 62 61 72 72 61 79 |loc_smal|l_barray|
|000042e0| 2c 0a 58 09 66 72 65 65 | 5f 73 6d 61 6c 6c 5f 62 |,.X.free|_small_b|
|000042f0| 61 72 72 61 79 3a 20 20 | 64 69 74 74 6f 20 66 6f |array: |ditto fo|
|00004300| 72 20 62 6c 6f 63 6b 20 | 28 63 6f 65 66 66 69 63 |r block |(coeffic|
|00004310| 69 65 6e 74 29 20 61 72 | 72 61 79 73 2e 0a 58 09 |ient) ar|rays..X.|
|00004320| 72 65 71 75 65 73 74 5f | 62 69 67 5f 73 61 72 72 |request_|big_sarr|
|00004330| 61 79 3a 20 20 72 65 71 | 75 65 73 74 20 61 20 76 |ay: req|uest a v|
|00004340| 69 72 74 75 61 6c 20 69 | 6d 61 67 65 20 73 61 6d |irtual i|mage sam|
|00004350| 70 6c 65 20 61 72 72 61 | 79 2e 20 20 54 68 65 20 |ple arra|y. The |
|00004360| 73 69 7a 65 0a 58 09 09 | 09 20 20 20 20 20 6f 66 |size.X..|. of|
|00004370| 20 74 68 65 20 69 6e 2d | 6d 65 6d 6f 72 79 20 62 | the in-|memory b|
|00004380| 75 66 66 65 72 20 77 69 | 6c 6c 20 62 65 20 64 65 |uffer wi|ll be de|
|00004390| 74 65 72 6d 69 6e 65 64 | 20 62 79 20 74 68 65 0a |termined| by the.|
|000043a0| 58 09 09 09 20 20 20 20 | 20 6d 65 6d 6f 72 79 20 |X... | memory |
|000043b0| 6d 61 6e 61 67 65 72 2c | 20 62 75 74 20 69 74 20 |manager,| but it |
|000043c0| 77 69 6c 6c 20 61 6c 77 | 61 79 73 20 62 65 20 61 |will alw|ays be a|
|000043d0| 20 6d 75 6c 74 69 70 6c | 65 0a 58 09 09 09 20 20 | multipl|e.X... |
|000043e0| 20 20 20 6f 66 20 74 68 | 65 20 70 61 73 73 65 64 | of th|e passed|
|000043f0| 2d 69 6e 20 4d 43 55 20 | 68 65 69 67 68 74 2e 0a |-in MCU |height..|
|00004400| 58 09 72 65 71 75 65 73 | 74 5f 62 69 67 5f 62 61 |X.reques|t_big_ba|
|00004410| 72 72 61 79 3a 20 20 64 | 69 74 74 6f 20 66 6f 72 |rray: d|itto for|
|00004420| 20 62 6c 6f 63 6b 20 28 | 63 6f 65 66 66 69 63 69 | block (|coeffici|
|00004430| 65 6e 74 29 20 61 72 72 | 61 79 73 2e 0a 58 09 61 |ent) arr|ays..X.a|
|00004440| 6c 6c 6f 63 5f 62 69 67 | 5f 61 72 72 61 79 73 3a |lloc_big|_arrays:|
|00004450| 20 20 69 6e 73 74 61 6e | 74 69 61 74 65 20 61 6c | instan|tiate al|
|00004460| 6c 20 74 68 65 20 62 69 | 67 20 61 72 72 61 79 73 |l the bi|g arrays|
|00004470| 20 70 72 65 76 69 6f 75 | 73 6c 79 20 72 65 71 75 | previou|sly requ|
|00004480| 65 73 74 65 64 2e 0a 58 | 09 09 09 20 20 20 54 68 |ested..X|... Th|
|00004490| 69 73 20 63 61 6c 6c 20 | 77 69 6c 6c 20 61 6c 73 |is call |will als|
|000044a0| 6f 20 70 61 73 73 20 73 | 6f 6d 65 20 69 6e 66 6f |o pass s|ome info|
|000044b0| 20 61 62 6f 75 74 20 66 | 75 74 75 72 65 0a 58 09 | about f|uture.X.|
|000044c0| 09 09 20 20 20 6d 65 6d | 6f 72 79 20 64 65 6d 61 |.. mem|ory dema|
|000044d0| 6e 64 73 2c 20 73 6f 20 | 74 68 61 74 20 74 68 65 |nds, so |that the|
|000044e0| 20 6d 65 6d 6f 72 79 20 | 6d 61 6e 61 67 65 72 20 | memory |manager |
|000044f0| 63 61 6e 0a 58 09 09 09 | 20 20 20 66 69 67 75 72 |can.X...| figur|
|00004500| 65 20 6f 75 74 20 68 6f | 77 20 6d 75 63 68 20 73 |e out ho|w much s|
|00004510| 70 61 63 65 20 74 6f 20 | 6c 65 61 76 65 20 75 6e |pace to |leave un|
|00004520| 61 6c 6c 6f 63 61 74 65 | 64 2e 0a 58 09 61 63 63 |allocate|d..X.acc|
|00004530| 65 73 73 5f 62 69 67 5f | 73 61 72 72 61 79 3a 20 |ess_big_|sarray: |
|00004540| 6f 62 74 61 69 6e 20 61 | 63 63 65 73 73 20 74 6f |obtain a|ccess to|
|00004550| 20 61 20 73 70 65 63 69 | 66 69 65 64 20 70 6f 72 | a speci|fied por|
|00004560| 74 69 6f 6e 20 6f 66 20 | 61 20 76 69 72 74 75 61 |tion of |a virtua|
|00004570| 6c 0a 58 09 09 09 20 20 | 20 69 6d 61 67 65 20 73 |l.X... | image s|
|00004580| 61 6d 70 6c 65 20 61 72 | 72 61 79 2e 0a 58 09 66 |ample ar|ray..X.f|
|00004590| 72 65 65 5f 62 69 67 5f | 73 61 72 72 61 79 3a 20 |ree_big_|sarray: |
|000045a0| 20 20 72 65 6c 65 61 73 | 65 20 61 20 76 69 72 74 | releas|e a virt|
|000045b0| 75 61 6c 20 73 61 6d 70 | 6c 65 20 61 72 72 61 79 |ual samp|le array|
|000045c0| 2e 0a 58 09 61 63 63 65 | 73 73 5f 62 69 67 5f 62 |..X.acce|ss_big_b|
|000045d0| 61 72 72 61 79 2c 0a 58 | 09 66 72 65 65 5f 62 69 |array,.X|.free_bi|
|000045e0| 67 5f 62 61 72 72 61 79 | 3a 20 20 20 64 69 74 74 |g_barray|: ditt|
|000045f0| 6f 20 66 6f 72 20 62 6c | 6f 63 6b 20 28 63 6f 65 |o for bl|ock (coe|
|00004600| 66 66 69 63 69 65 6e 74 | 29 20 61 72 72 61 79 73 |fficient|) arrays|
|00004610| 2e 0a 58 09 66 72 65 65 | 5f 61 6c 6c 3a 09 20 20 |..X.free|_all:. |
|00004620| 20 72 65 6c 65 61 73 65 | 20 61 6e 79 20 72 65 6d | release| any rem|
|00004630| 61 69 6e 69 6e 67 20 73 | 74 6f 72 61 67 65 2e 20 |aining s|torage. |
|00004640| 20 54 68 69 73 20 69 73 | 20 63 61 6c 6c 65 64 0a | This is| called.|
|00004650| 58 09 09 09 20 20 20 62 | 65 66 6f 72 65 20 6e 6f |X... b|efore no|
|00004660| 72 6d 61 6c 20 6f 72 20 | 65 72 72 6f 72 20 74 65 |rmal or |error te|
|00004670| 72 6d 69 6e 61 74 69 6f | 6e 3b 20 74 68 65 20 6d |rminatio|n; the m|
|00004680| 61 69 6e 20 72 65 61 73 | 6f 6e 0a 58 09 09 09 20 |ain reas|on.X... |
|00004690| 20 20 77 68 79 20 69 74 | 20 6d 75 73 74 20 65 78 | why it| must ex|
|000046a0| 69 73 74 20 69 73 20 74 | 6f 20 65 6e 73 75 72 65 |ist is t|o ensure|
|000046b0| 20 74 68 61 74 20 61 6e | 79 20 74 65 6d 70 6f 72 | that an|y tempor|
|000046c0| 61 72 79 0a 58 09 09 09 | 20 20 20 66 69 6c 65 73 |ary.X...| files|
|000046d0| 20 77 69 6c 6c 20 62 65 | 20 64 65 6c 65 74 65 64 | will be| deleted|
|000046e0| 20 75 70 6f 6e 20 65 72 | 72 6f 72 20 74 65 72 6d | upon er|ror term|
|000046f0| 69 6e 61 74 69 6f 6e 2e | 0a 58 0a 58 20 20 20 20 |ination.|.X.X |
|00004700| 61 6c 6c 6f 63 5f 62 69 | 67 5f 61 72 72 61 79 73 |alloc_bi|g_arrays|
|00004710| 20 77 69 6c 6c 20 62 65 | 20 63 61 6c 6c 65 64 20 | will be| called |
|00004720| 62 79 20 74 68 65 20 70 | 69 70 65 6c 69 6e 65 20 |by the p|ipeline |
|00004730| 63 6f 6e 74 72 6f 6c 6c | 65 72 2c 20 77 68 69 63 |controll|er, whic|
|00004740| 68 20 64 6f 65 73 0a 58 | 20 20 20 20 6d 6f 73 74 |h does.X| most|
|00004750| 20 6f 66 20 74 68 65 20 | 6d 65 6d 6f 72 79 20 61 | of the |memory a|
|00004760| 6c 6c 6f 63 61 74 69 6f | 6e 20 61 6e 79 77 61 79 |llocatio|n anyway|
|00004770| 2e 20 20 54 68 65 20 6f | 6e 6c 79 20 72 65 61 73 |. The o|nly reas|
|00004780| 6f 6e 20 66 6f 72 20 68 | 61 76 69 6e 67 20 73 65 |on for h|aving se|
|00004790| 70 61 72 61 74 65 0a 58 | 20 20 20 20 72 65 71 75 |parate.X| requ|
|000047a0| 65 73 74 20 63 61 6c 6c | 73 20 69 73 20 74 6f 20 |est call|s is to |
|000047b0| 61 6c 6c 6f 77 20 73 6f | 6d 65 20 6f 66 20 74 68 |allow so|me of th|
|000047c0| 65 20 6f 74 68 65 72 20 | 6d 6f 64 75 6c 65 73 20 |e other |modules |
|000047d0| 74 6f 20 67 65 74 20 62 | 69 67 20 61 72 72 61 79 |to get b|ig array|
|000047e0| 73 2e 0a 58 20 20 20 20 | 54 68 65 20 70 69 70 65 |s..X |The pipe|
|000047f0| 6c 69 6e 65 20 63 6f 6e | 74 72 6f 6c 6c 65 72 20 |line con|troller |
|00004800| 69 73 20 72 65 71 75 69 | 72 65 64 20 74 6f 20 67 |is requi|red to g|
|00004810| 69 76 65 20 61 6e 20 75 | 70 70 65 72 20 62 6f 75 |ive an u|pper bou|
|00004820| 6e 64 20 6f 6e 20 74 6f | 74 61 6c 20 66 75 74 75 |nd on to|tal futu|
|00004830| 72 65 0a 58 20 20 20 20 | 73 6d 61 6c 6c 2d 61 72 |re.X |small-ar|
|00004840| 72 61 79 20 72 65 71 75 | 65 73 74 73 2c 20 73 6f |ray requ|ests, so|
|00004850| 20 74 68 61 74 20 74 68 | 69 73 20 73 70 61 63 65 | that th|is space|
|00004860| 20 63 61 6e 20 62 65 20 | 64 69 73 63 6f 75 6e 74 | can be |discount|
|00004870| 65 64 2e 20 20 28 41 20 | 66 61 69 72 6c 79 0a 58 |ed. (A |fairly.X|
|00004880| 20 20 20 20 63 6f 6e 73 | 65 72 76 61 74 69 76 65 | cons|ervative|
|00004890| 20 65 73 74 69 6d 61 74 | 65 20 77 69 6c 6c 20 62 | estimat|e will b|
|000048a0| 65 20 61 64 65 71 75 61 | 74 65 2e 29 20 20 46 75 |e adequa|te.) Fu|
|000048b0| 74 75 72 65 20 73 6d 61 | 6c 6c 2d 6f 62 6a 65 63 |ture sma|ll-objec|
|000048c0| 74 20 72 65 71 75 65 73 | 74 73 0a 58 20 20 20 20 |t reques|ts.X |
|000048d0| 61 72 65 6e 27 74 20 63 | 6f 75 6e 74 65 64 3b 20 |aren't c|ounted; |
|000048e0| 74 68 65 20 6d 65 6d 6f | 72 79 20 6d 61 6e 61 67 |the memo|ry manag|
|000048f0| 65 72 20 68 61 73 20 74 | 6f 20 75 73 65 20 61 20 |er has t|o use a |
|00004900| 73 6c 6f 70 20 66 61 63 | 74 6f 72 20 66 6f 72 20 |slop fac|tor for |
|00004910| 74 68 6f 73 65 2e 0a 58 | 20 20 20 20 31 30 4b 20 |those..X| 10K |
|00004920| 6f 72 20 73 6f 20 73 65 | 65 6d 73 20 74 6f 20 62 |or so se|ems to b|
|00004930| 65 20 73 75 66 66 69 63 | 69 65 6e 74 2e 20 20 28 |e suffic|ient. (|
|00004940| 49 6e 20 61 6e 20 38 30 | 78 38 36 2c 20 73 6d 61 |In an 80|x86, sma|
|00004950| 6c 6c 20 6f 62 6a 65 63 | 74 73 20 61 72 65 6e 27 |ll objec|ts aren'|
|00004960| 74 20 61 6e 0a 58 20 20 | 20 20 69 73 73 75 65 20 |t an.X | issue |
|00004970| 61 6e 79 77 61 79 2c 20 | 73 69 6e 63 65 20 74 68 |anyway, |since th|
|00004980| 65 79 20 64 6f 6e 27 74 | 20 63 6f 6d 70 65 74 65 |ey don't| compete|
|00004990| 20 66 6f 72 20 66 61 72 | 2d 68 65 61 70 20 73 70 | for far|-heap sp|
|000049a0| 61 63 65 2e 20 20 22 4d | 65 64 69 75 6d 22 2d 73 |ace. "M|edium"-s|
|000049b0| 69 7a 65 0a 58 20 20 20 | 20 6f 62 6a 65 63 74 73 |ize.X | objects|
|000049c0| 20 77 69 6c 6c 20 68 61 | 76 65 20 74 6f 20 62 65 | will ha|ve to be|
|000049d0| 20 63 6f 75 6e 74 65 64 | 20 73 65 70 61 72 61 74 | counted| separat|
|000049e0| 65 6c 79 2e 29 0a 58 0a | 58 20 20 20 20 54 68 65 |ely.).X.|X The|
|000049f0| 20 64 69 73 74 69 6e 63 | 74 69 6f 6e 20 62 65 74 | distinc|tion bet|
|00004a00| 77 65 65 6e 20 73 61 6d | 70 6c 65 20 61 6e 64 20 |ween sam|ple and |
|00004a10| 63 6f 65 66 66 69 63 69 | 65 6e 74 20 61 72 72 61 |coeffici|ent arra|
|00004a20| 79 20 72 6f 75 74 69 6e | 65 73 20 69 73 20 61 6e |y routin|es is an|
|00004a30| 6e 6f 79 69 6e 67 2c 0a | 58 20 20 20 20 62 75 74 |noying,.|X but|
|00004a40| 20 69 74 20 68 61 73 20 | 74 6f 20 62 65 20 6d 61 | it has |to be ma|
|00004a50| 69 6e 74 61 69 6e 65 64 | 20 66 6f 72 20 6d 61 63 |intained| for mac|
|00004a60| 68 69 6e 65 73 20 69 6e | 20 77 68 69 63 68 20 22 |hines in| which "|
|00004a70| 63 68 61 72 20 2a 22 20 | 69 73 20 72 65 70 72 65 |char *" |is repre|
|00004a80| 73 65 6e 74 65 64 0a 58 | 20 20 20 20 64 69 66 66 |sented.X| diff|
|00004a90| 65 72 65 6e 74 6c 79 20 | 66 72 6f 6d 20 22 69 6e |erently |from "in|
|00004aa0| 74 20 2a 22 2e 20 20 4f | 6e 20 62 79 74 65 2d 61 |t *". O|n byte-a|
|00004ab0| 64 64 72 65 73 73 61 62 | 6c 65 20 6d 61 63 68 69 |ddressab|le machi|
|00004ac0| 6e 65 73 20 73 6f 6d 65 | 20 6f 66 20 74 68 65 73 |nes some| of thes|
|00004ad0| 65 0a 58 20 20 20 20 6d | 65 74 68 6f 64 73 20 63 |e.X m|ethods c|
|00004ae0| 6f 75 6c 64 20 70 65 72 | 68 61 70 73 20 70 6f 69 |ould per|haps poi|
|00004af0| 6e 74 20 74 6f 20 74 68 | 65 20 73 61 6d 65 20 63 |nt to th|e same c|
|00004b00| 6f 64 65 2e 0a 58 0a 58 | 20 20 20 20 54 68 65 20 |ode..X.X| The |
|00004b10| 61 72 72 61 79 20 72 6f | 75 74 69 6e 65 73 20 77 |array ro|utines w|
|00004b20| 69 6c 6c 20 6f 70 65 72 | 61 74 65 20 6f 6e 20 6f |ill oper|ate on o|
|00004b30| 6e 6c 79 20 32 2d 44 20 | 61 72 72 61 79 73 20 28 |nly 2-D |arrays (|
|00004b40| 6f 6e 65 20 63 6f 6d 70 | 6f 6e 65 6e 74 20 61 74 |one comp|onent at|
|00004b50| 20 61 0a 58 20 20 20 20 | 74 69 6d 65 29 2c 20 73 | a.X |time), s|
|00004b60| 69 6e 63 65 20 64 69 66 | 66 65 72 65 6e 74 20 63 |ince dif|ferent c|
|00004b70| 6f 6d 70 6f 6e 65 6e 74 | 73 20 6d 61 79 20 72 65 |omponent|s may re|
|00004b80| 71 75 69 72 65 20 64 69 | 66 66 65 72 65 6e 74 2d |quire di|fferent-|
|00004b90| 73 69 7a 65 20 61 72 72 | 61 79 73 2e 0a 58 0a 58 |size arr|ays..X.X|
|00004ba0| 20 20 20 20 28 54 68 69 | 73 20 6f 62 6a 65 63 74 | (Thi|s object|
|00004bb0| 20 68 69 64 65 73 20 74 | 68 65 20 6b 6e 6f 77 6c | hides t|he knowl|
|00004bc0| 65 64 67 65 20 6f 66 20 | 77 68 65 74 68 65 72 20 |edge of |whether |
|00004bd0| 76 69 72 74 75 61 6c 20 | 6d 65 6d 6f 72 79 20 69 |virtual |memory i|
|00004be0| 73 20 61 76 61 69 6c 61 | 62 6c 65 2c 0a 58 20 20 |s availa|ble,.X |
|00004bf0| 20 20 61 73 20 77 65 6c | 6c 20 61 73 20 74 68 65 | as wel|l as the|
|00004c00| 20 61 63 74 75 61 6c 20 | 69 6e 74 65 72 66 61 63 | actual |interfac|
|00004c10| 65 20 74 6f 20 4f 53 20 | 61 6e 64 20 6c 69 62 72 |e to OS |and libr|
|00004c20| 61 72 79 20 73 75 70 70 | 6f 72 74 20 72 6f 75 74 |ary supp|ort rout|
|00004c30| 69 6e 65 73 2e 29 0a 58 | 0a 58 4e 6f 74 65 20 74 |ines.).X|.XNote t|
|00004c40| 68 61 74 20 61 6e 79 20 | 67 69 76 65 6e 20 69 6d |hat any |given im|
|00004c50| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 20 77 69 6c |plementa|tion wil|
|00004c60| 6c 20 70 72 65 73 75 6d | 61 62 6c 79 20 63 6f 6e |l presum|ably con|
|00004c70| 74 61 69 6e 20 6f 6e 6c | 79 20 6f 6e 65 0a 58 69 |tain onl|y one.Xi|
|00004c80| 6e 73 74 61 6e 74 69 61 | 74 69 6f 6e 20 6f 66 20 |nstantia|tion of |
|00004c90| 69 6e 70 75 74 20 66 69 | 6c 65 20 68 65 61 64 65 |input fi|le heade|
|00004ca0| 72 20 72 65 61 64 69 6e | 67 2c 20 6f 76 65 72 61 |r readin|g, overa|
|00004cb0| 6c 6c 20 63 6f 6e 74 72 | 6f 6c 2c 20 75 73 65 72 |ll contr|ol, user|
|00004cc0| 20 69 6e 74 65 72 66 61 | 63 65 2c 0a 58 61 6e 64 | interfa|ce,.Xand|
|00004cd0| 20 6d 65 6d 6f 72 79 20 | 6d 61 6e 61 67 65 6d 65 | memory |manageme|
|00004ce0| 6e 74 2e 20 20 54 68 75 | 73 20 74 68 65 73 65 20 |nt. Thu|s these |
|00004cf0| 63 6f 75 6c 64 20 62 65 | 20 63 61 6c 6c 65 64 20 |could be| called |
|00004d00| 61 73 20 73 69 6d 70 6c | 65 20 73 75 62 72 6f 75 |as simpl|e subrou|
|00004d10| 74 69 6e 65 73 2c 0a 58 | 77 69 74 68 6f 75 74 20 |tines,.X|without |
|00004d20| 62 6f 74 68 65 72 69 6e | 67 20 77 69 74 68 20 61 |botherin|g with a|
|00004d30| 6e 20 6f 62 6a 65 63 74 | 20 69 6e 64 69 72 65 63 |n object| indirec|
|00004d40| 74 69 6f 6e 2e 20 20 54 | 68 69 73 20 69 73 20 65 |tion. T|his is e|
|00004d50| 73 73 65 6e 74 69 61 6c | 20 66 6f 72 20 6f 76 65 |ssential| for ove|
|00004d60| 72 61 6c 6c 0a 58 63 6f | 6e 74 72 6f 6c 20 28 77 |rall.Xco|ntrol (w|
|00004d70| 68 69 63 68 20 68 61 73 | 20 74 6f 20 69 6e 69 74 |hich has| to init|
|00004d80| 69 61 6c 69 7a 65 20 74 | 68 65 20 6f 62 6a 65 63 |ialize t|he objec|
|00004d90| 74 20 73 74 72 75 63 74 | 75 72 65 29 3b 20 66 6f |t struct|ure); fo|
|00004da0| 72 20 63 6f 6e 73 69 73 | 74 65 6e 63 79 20 77 65 |r consis|tency we|
|00004db0| 0a 58 77 69 6c 6c 20 69 | 6d 70 6f 73 65 20 6f 62 |.Xwill i|mpose ob|
|00004dc0| 6a 65 63 74 6e 65 73 73 | 20 6f 6e 20 74 68 65 20 |jectness| on the |
|00004dd0| 6f 74 68 65 72 20 74 68 | 72 65 65 2e 0a 58 0a 58 |other th|ree..X.X|
|00004de0| 0a 58 2a 2a 2a 20 44 65 | 63 6f 6d 70 72 65 73 73 |.X*** De|compress|
|00004df0| 69 6f 6e 20 6f 62 6a 65 | 63 74 20 73 74 72 75 63 |ion obje|ct struc|
|00004e00| 74 75 72 65 20 2a 2a 2a | 0a 58 0a 58 49 20 70 72 |ture ***|.X.XI pr|
|00004e10| 6f 70 6f 73 65 20 74 68 | 65 20 66 6f 6c 6c 6f 77 |opose th|e follow|
|00004e20| 69 6e 67 20 73 65 74 20 | 6f 66 20 6f 62 6a 65 63 |ing set |of objec|
|00004e30| 74 73 20 66 6f 72 20 64 | 65 63 6f 6d 70 72 65 73 |ts for d|ecompres|
|00004e40| 73 69 6f 6e 2e 20 20 54 | 68 65 20 67 65 6e 65 72 |sion. T|he gener|
|00004e50| 61 6c 0a 58 63 6f 6d 6d | 65 6e 74 73 20 61 74 20 |al.Xcomm|ents at |
|00004e60| 74 68 65 20 74 6f 70 20 | 6f 66 20 74 68 65 20 63 |the top |of the c|
|00004e70| 6f 6d 70 72 65 73 73 69 | 6f 6e 20 6f 62 6a 65 63 |ompressi|on objec|
|00004e80| 74 20 73 65 63 74 69 6f | 6e 20 61 6c 73 6f 20 61 |t sectio|n also a|
|00004e90| 70 70 6c 79 20 68 65 72 | 65 2e 0a 58 0a 58 31 2e |pply her|e..X.X1.|
|00004ea0| 20 4a 50 45 47 20 66 69 | 6c 65 20 73 63 61 6e 6e | JPEG fi|le scann|
|00004eb0| 69 6e 67 2e 20 20 54 68 | 69 73 20 77 69 6c 6c 20 |ing. Th|is will |
|00004ec0| 70 72 6f 76 69 64 65 20 | 74 68 65 73 65 20 6d 65 |provide |these me|
|00004ed0| 74 68 6f 64 73 3a 0a 58 | 09 72 65 61 64 5f 66 69 |thods:.X|.read_fi|
|00004ee0| 6c 65 5f 68 65 61 64 65 | 72 3a 20 72 65 61 64 20 |le_heade|r: read |
|00004ef0| 74 68 65 20 66 69 6c 65 | 20 68 65 61 64 65 72 2c |the file| header,|
|00004f00| 20 64 65 74 65 72 6d 69 | 6e 65 20 77 68 69 63 68 | determi|ne which|
|00004f10| 20 76 61 72 69 61 6e 74 | 0a 58 09 09 09 20 20 4a | variant|.X... J|
|00004f20| 50 45 47 20 66 6f 72 6d | 61 74 20 69 73 20 69 6e |PEG form|at is in|
|00004f30| 20 75 73 65 2c 20 72 65 | 61 64 20 65 76 65 72 79 | use, re|ad every|
|00004f40| 74 68 69 6e 67 20 74 68 | 72 6f 75 67 68 20 53 4f |thing th|rough SO|
|00004f50| 46 2e 0a 58 09 72 65 61 | 64 5f 73 63 61 6e 5f 68 |F..X.rea|d_scan_h|
|00004f60| 65 61 64 65 72 3a 20 72 | 65 61 64 20 73 63 61 6e |eader: r|ead scan|
|00004f70| 20 68 65 61 64 65 72 20 | 28 75 70 20 74 68 72 6f | header |(up thro|
|00004f80| 75 67 68 20 53 4f 53 29 | 2e 20 20 54 68 69 73 20 |ugh SOS)|. This |
|00004f90| 69 73 20 63 61 6c 6c 65 | 64 0a 58 09 09 09 20 20 |is calle|d.X... |
|00004fa0| 61 66 74 65 72 20 72 65 | 61 64 5f 66 69 6c 65 5f |after re|ad_file_|
|00004fb0| 68 65 61 64 65 72 20 61 | 6e 64 20 61 67 61 69 6e |header a|nd again|
|00004fc0| 20 61 66 74 65 72 20 65 | 61 63 68 20 73 63 61 6e | after e|ach scan|
|00004fd0| 3b 0a 58 09 09 09 20 20 | 69 74 20 72 65 74 75 72 |;.X... |it retur|
|00004fe0| 6e 73 20 54 52 55 45 20 | 69 66 20 69 74 20 66 69 |ns TRUE |if it fi|
|00004ff0| 6e 64 73 20 53 4f 53 2c | 20 46 41 4c 53 45 20 69 |nds SOS,| FALSE i|
|00005000| 66 20 45 4f 49 2e 0a 58 | 09 72 65 61 64 5f 6a 70 |f EOI..X|.read_jp|
|00005010| 65 67 5f 64 61 74 61 3a | 20 66 65 74 63 68 20 64 |eg_data:| fetch d|
|00005020| 61 74 61 20 66 6f 72 20 | 65 6e 74 72 6f 70 79 20 |ata for |entropy |
|00005030| 64 65 63 6f 64 65 72 2e | 0a 58 09 72 65 73 79 6e |decoder.|.X.resyn|
|00005040| 63 5f 74 6f 5f 72 65 73 | 74 61 72 74 3a 20 74 72 |c_to_res|tart: tr|
|00005050| 79 20 74 6f 20 72 65 63 | 6f 76 65 72 20 66 72 6f |y to rec|over fro|
|00005060| 6d 20 62 6f 67 75 73 20 | 64 61 74 61 20 28 73 65 |m bogus |data (se|
|00005070| 65 20 62 65 6c 6f 77 29 | 2e 0a 58 09 72 65 61 64 |e below)|..X.read|
|00005080| 5f 73 63 61 6e 5f 74 72 | 61 69 6c 65 72 3a 20 66 |_scan_tr|ailer: f|
|00005090| 69 6e 69 73 68 20 75 70 | 20 61 66 74 65 72 20 6f |inish up| after o|
|000050a0| 6e 65 20 73 63 61 6e 2c | 20 70 72 65 70 61 72 65 |ne scan,| prepare|
|000050b0| 20 66 6f 72 20 61 6e 6f | 74 68 65 72 20 63 61 6c | for ano|ther cal|
|000050c0| 6c 0a 58 09 09 09 20 20 | 20 6f 66 20 72 65 61 64 |l.X... | of read|
|000050d0| 5f 73 63 61 6e 5f 68 65 | 61 64 65 72 20 28 6d 61 |_scan_he|ader (ma|
|000050e0| 79 20 62 65 20 61 20 6e | 6f 2d 6f 70 29 2e 0a 58 |y be a n|o-op)..X|
|000050f0| 09 72 65 61 64 5f 66 69 | 6c 65 5f 74 72 61 69 6c |.read_fi|le_trail|
|00005100| 65 72 3a 20 66 69 6e 69 | 73 68 20 75 70 20 61 74 |er: fini|sh up at|
|00005110| 20 65 6e 64 20 6f 66 20 | 66 69 6c 65 20 28 70 72 | end of |file (pr|
|00005120| 6f 62 61 62 6c 79 20 61 | 20 6e 6f 2d 6f 70 29 2e |obably a| no-op).|
|00005130| 0a 58 20 20 20 54 68 65 | 20 65 6e 74 72 6f 70 79 |.X The| entropy|
|00005140| 20 64 65 63 6f 64 65 72 | 20 6d 75 73 74 20 64 65 | decoder| must de|
|00005150| 61 6c 20 77 69 74 68 20 | 72 65 73 74 61 72 74 20 |al with |restart |
|00005160| 6d 61 72 6b 65 72 73 2c | 20 62 75 74 20 61 6c 6c |markers,| but all|
|00005170| 20 6f 74 68 65 72 20 4a | 50 45 47 0a 58 20 20 20 | other J|PEG.X |
|00005180| 6d 61 72 6b 65 72 20 74 | 79 70 65 73 20 77 69 6c |marker t|ypes wil|
|00005190| 6c 20 62 65 20 68 61 6e | 64 6c 65 64 20 69 6e 20 |l be han|dled in |
|000051a0| 74 68 69 73 20 6f 62 6a | 65 63 74 3b 20 75 73 65 |this obj|ect; use|
|000051b0| 66 75 6c 20 64 61 74 61 | 20 66 72 6f 6d 20 74 68 |ful data| from th|
|000051c0| 65 20 6d 61 72 6b 65 72 | 73 0a 58 20 20 20 77 69 |e marker|s.X wi|
|000051d0| 6c 6c 20 62 65 20 65 78 | 74 72 61 63 74 65 64 20 |ll be ex|tracted |
|000051e0| 69 6e 74 6f 20 64 61 74 | 61 20 73 74 72 75 63 74 |into dat|a struct|
|000051f0| 75 72 65 73 20 61 76 61 | 69 6c 61 62 6c 65 20 74 |ures ava|ilable t|
|00005200| 6f 20 73 75 62 73 65 71 | 75 65 6e 74 20 72 6f 75 |o subseq|uent rou|
|00005210| 74 69 6e 65 73 2e 0a 58 | 20 20 20 4e 6f 74 65 20 |tines..X| Note |
|00005220| 74 68 61 74 20 6f 6e 20 | 65 78 69 74 20 66 72 6f |that on |exit fro|
|00005230| 6d 20 72 65 61 64 5f 66 | 69 6c 65 5f 68 65 61 64 |m read_f|ile_head|
|00005240| 65 72 2c 20 6f 6e 6c 79 | 20 74 68 65 20 53 4f 46 |er, only| the SOF|
|00005250| 2d 6d 61 72 6b 65 72 20 | 64 61 74 61 20 73 68 6f |-marker |data sho|
|00005260| 75 6c 64 20 62 65 0a 58 | 20 20 20 61 73 73 75 6d |uld be.X| assum|
|00005270| 65 64 20 76 61 6c 69 64 | 20 28 69 6d 61 67 65 20 |ed valid| (image |
|00005280| 73 69 7a 65 2c 20 63 6f | 6d 70 6f 6e 65 6e 74 20 |size, co|mponent |
|00005290| 49 44 73 2c 20 73 61 6d | 70 6c 69 6e 67 20 66 61 |IDs, sam|pling fa|
|000052a0| 63 74 6f 72 73 29 3b 20 | 6f 74 68 65 72 20 64 61 |ctors); |other da|
|000052b0| 74 61 0a 58 20 20 20 73 | 75 63 68 20 61 73 20 48 |ta.X s|uch as H|
|000052c0| 75 66 66 6d 61 6e 20 74 | 61 62 6c 65 73 20 6d 61 |uffman t|ables ma|
|000052d0| 79 20 6e 6f 74 20 61 70 | 70 65 61 72 20 75 6e 74 |y not ap|pear unt|
|000052e0| 69 6c 20 61 66 74 65 72 | 20 74 68 65 20 53 4f 46 |il after| the SOF|
|000052f0| 2e 20 20 54 68 65 20 6f | 76 65 72 61 6c 6c 0a 58 |. The o|verall.X|
|00005300| 20 20 20 69 6d 61 67 65 | 20 73 69 7a 65 20 61 6e | image| size an|
|00005310| 64 20 63 6f 6c 6f 72 73 | 70 61 63 65 20 63 61 6e |d colors|pace can|
|00005320| 20 62 65 20 64 65 74 65 | 72 6d 69 6e 65 64 20 61 | be dete|rmined a|
|00005330| 66 74 65 72 20 72 65 61 | 64 5f 66 69 6c 65 5f 68 |fter rea|d_file_h|
|00005340| 65 61 64 65 72 2c 20 62 | 75 74 20 6e 6f 74 0a 58 |eader, b|ut not.X|
|00005350| 20 20 20 77 68 65 74 68 | 65 72 20 6f 72 20 68 6f | wheth|er or ho|
|00005360| 77 20 74 68 65 20 64 61 | 74 61 20 69 73 20 69 6e |w the da|ta is in|
|00005370| 74 65 72 6c 65 61 76 65 | 64 2e 20 20 28 54 68 69 |terleave|d. (Thi|
|00005380| 73 20 68 69 64 65 73 20 | 77 68 69 63 68 20 76 61 |s hides |which va|
|00005390| 72 69 61 6e 74 20 4a 50 | 45 47 0a 58 20 20 20 66 |riant JP|EG.X f|
|000053a0| 69 6c 65 20 66 6f 72 6d | 61 74 20 69 73 20 62 65 |ile form|at is be|
|000053b0| 69 6e 67 20 72 65 61 64 | 2e 20 20 49 6e 20 70 61 |ing read|. In pa|
|000053c0| 72 74 69 63 75 6c 61 72 | 2c 20 66 6f 72 20 4a 50 |rticular|, for JP|
|000053d0| 45 47 2d 69 6e 2d 54 49 | 46 46 20 74 68 65 20 72 |EG-in-TI|FF the r|
|000053e0| 65 61 64 5f 68 65 61 64 | 65 72 0a 58 20 20 20 72 |ead_head|er.X r|
|000053f0| 6f 75 74 69 6e 65 73 20 | 6d 69 67 68 74 20 6e 6f |outines |might no|
|00005400| 74 20 62 65 20 73 63 61 | 6e 6e 69 6e 67 20 73 74 |t be sca|nning st|
|00005410| 61 6e 64 61 72 64 20 4a | 50 45 47 20 6d 61 72 6b |andard J|PEG mark|
|00005420| 65 72 73 20 61 74 20 61 | 6c 6c 3b 20 74 68 65 79 |ers at a|ll; they|
|00005430| 20 63 6f 75 6c 64 0a 58 | 20 20 20 65 78 74 72 61 | could.X| extra|
|00005440| 63 74 20 74 68 65 20 64 | 61 74 61 20 66 72 6f 6d |ct the d|ata from|
|00005450| 20 54 49 46 46 20 74 61 | 67 73 2e 20 20 54 68 65 | TIFF ta|gs. The|
|00005460| 20 75 73 65 72 20 69 6e | 74 65 72 66 61 63 65 20 | user in|terface |
|00005470| 77 69 6c 6c 20 61 6c 72 | 65 61 64 79 20 68 61 76 |will alr|eady hav|
|00005480| 65 0a 58 20 20 20 6f 70 | 65 6e 65 64 20 74 68 65 |e.X op|ened the|
|00005490| 20 69 6e 70 75 74 20 66 | 69 6c 65 20 61 6e 64 20 | input f|ile and |
|000054a0| 70 6f 73 73 69 62 6c 79 | 20 72 65 61 64 20 70 61 |possibly| read pa|
|000054b0| 72 74 20 6f 66 20 74 68 | 65 20 68 65 61 64 65 72 |rt of th|e header|
|000054c0| 20 62 65 66 6f 72 65 0a | 58 20 20 20 72 65 61 64 | before.|X read|
|000054d0| 5f 66 69 6c 65 5f 68 65 | 61 64 65 72 20 69 73 20 |_file_he|ader is |
|000054e0| 63 61 6c 6c 65 64 2e 29 | 0a 58 0a 58 20 20 20 57 |called.)|.X.X W|
|000054f0| 68 65 6e 20 72 65 61 64 | 69 6e 67 20 61 20 66 69 |hen read|ing a fi|
|00005500| 6c 65 20 77 69 74 68 20 | 61 20 6e 6f 6e 7a 65 72 |le with |a nonzer|
|00005510| 6f 20 72 65 73 74 61 72 | 74 20 69 6e 74 65 72 76 |o restar|t interv|
|00005520| 61 6c 2c 20 74 68 65 20 | 65 6e 74 72 6f 70 79 20 |al, the |entropy |
|00005530| 64 65 63 6f 64 65 72 0a | 58 20 20 20 65 78 70 65 |decoder.|X expe|
|00005540| 63 74 73 20 74 6f 20 73 | 65 65 20 61 20 63 6f 72 |cts to s|ee a cor|
|00005550| 72 65 63 74 20 73 65 71 | 75 65 6e 63 65 20 6f 66 |rect seq|uence of|
|00005560| 20 72 65 73 74 61 72 74 | 20 6d 61 72 6b 65 72 73 | restart| markers|
|00005570| 2e 20 20 49 6e 20 73 6f | 6d 65 20 63 61 73 65 73 |. In so|me cases|
|00005580| 2c 20 74 68 65 73 65 0a | 58 20 20 20 6d 61 72 6b |, these.|X mark|
|00005590| 65 72 73 20 6d 61 79 20 | 62 65 20 73 79 6e 74 68 |ers may |be synth|
|000055a0| 65 73 69 7a 65 64 20 62 | 79 20 74 68 65 20 66 69 |esized b|y the fi|
|000055b0| 6c 65 2d 66 6f 72 6d 61 | 74 20 6d 6f 64 75 6c 65 |le-forma|t module|
|000055c0| 20 28 61 20 54 49 46 46 | 20 72 65 61 64 65 72 20 | (a TIFF| reader |
|000055d0| 6d 69 67 68 74 0a 58 20 | 20 20 64 6f 20 73 6f 2c |might.X | do so,|
|000055e0| 20 66 6f 72 20 65 78 61 | 6d 70 6c 65 2c 20 75 73 | for exa|mple, us|
|000055f0| 69 6e 67 20 74 69 6c 65 | 20 62 6f 75 6e 64 61 72 |ing tile| boundar|
|00005600| 79 20 70 6f 69 6e 74 65 | 72 73 20 74 6f 20 64 65 |y pointe|rs to de|
|00005610| 74 65 72 6d 69 6e 65 20 | 77 68 65 72 65 20 74 68 |termine |where th|
|00005620| 65 0a 58 20 20 20 72 65 | 73 74 61 72 74 20 69 6e |e.X re|start in|
|00005630| 74 65 72 76 61 6c 73 20 | 66 61 6c 6c 29 2e 20 20 |tervals |fall). |
|00005640| 49 66 20 74 68 65 20 69 | 6e 63 6f 6d 69 6e 67 20 |If the i|ncoming |
|00005650| 64 61 74 61 20 69 73 20 | 63 6f 72 72 75 70 74 65 |data is |corrupte|
|00005660| 64 2c 20 74 68 65 20 65 | 6e 74 72 6f 70 79 0a 58 |d, the e|ntropy.X|
|00005670| 20 20 20 64 65 63 6f 64 | 65 72 20 77 69 6c 6c 20 | decod|er will |
|00005680| 72 65 61 64 20 61 73 20 | 66 61 72 20 61 73 20 74 |read as |far as t|
|00005690| 68 65 20 6e 65 78 74 20 | 4a 50 45 47 20 6d 61 72 |he next |JPEG mar|
|000056a0| 6b 65 72 2c 20 77 68 69 | 63 68 20 6d 61 79 20 6f |ker, whi|ch may o|
|000056b0| 72 20 6d 61 79 20 6e 6f | 74 20 62 65 0a 58 20 20 |r may no|t be.X |
|000056c0| 20 74 68 65 20 65 78 70 | 65 63 74 65 64 20 6e 65 | the exp|ected ne|
|000056d0| 78 74 20 72 65 73 74 61 | 72 74 20 6d 61 72 6b 65 |xt resta|rt marke|
|000056e0| 72 2e 20 20 49 66 20 69 | 74 20 69 73 6e 27 74 2c |r. If i|t isn't,|
|000056f0| 20 72 65 73 79 6e 63 5f | 74 6f 5f 72 65 73 74 61 | resync_|to_resta|
|00005700| 72 74 20 69 73 20 63 61 | 6c 6c 65 64 0a 58 20 20 |rt is ca|lled.X |
|00005710| 20 74 6f 20 74 72 79 20 | 74 6f 20 6c 6f 63 61 74 | to try |to locat|
|00005720| 65 20 61 20 67 6f 6f 64 | 20 70 6c 61 63 65 20 74 |e a good| place t|
|00005730| 6f 20 72 65 73 75 6d 65 | 20 72 65 61 64 69 6e 67 |o resume| reading|
|00005740| 2e 20 20 57 65 20 6d 61 | 6b 65 20 74 68 69 73 20 |. We ma|ke this |
|00005750| 68 65 75 72 69 73 74 69 | 63 20 61 0a 58 20 20 20 |heuristi|c a.X |
|00005760| 66 69 6c 65 2d 66 6f 72 | 6d 61 74 2d 64 65 70 65 |file-for|mat-depe|
|00005770| 6e 64 65 6e 74 20 6f 70 | 65 72 61 74 69 6f 6e 20 |ndent op|eration |
|00005780| 73 69 6e 63 65 20 73 6f | 6d 65 20 66 69 6c 65 20 |since so|me file |
|00005790| 66 6f 72 6d 61 74 73 20 | 6d 61 79 20 68 61 76 65 |formats |may have|
|000057a0| 20 73 70 65 63 69 61 6c | 0a 58 20 20 20 69 6e 66 | special|.X inf|
|000057b0| 6f 20 74 68 61 74 27 73 | 20 6e 6f 74 20 61 76 61 |o that's| not ava|
|000057c0| 69 6c 61 62 6c 65 20 74 | 6f 20 74 68 65 20 65 6e |ilable t|o the en|
|000057d0| 74 72 6f 70 79 20 64 65 | 63 6f 64 65 72 20 28 61 |tropy de|coder (a|
|000057e0| 67 61 69 6e 2c 20 54 49 | 46 46 20 69 73 20 61 6e |gain, TI|FF is an|
|000057f0| 0a 58 20 20 20 65 78 61 | 6d 70 6c 65 29 2e 20 20 |.X exa|mple). |
|00005800| 4e 6f 74 65 20 74 68 61 | 74 20 72 65 73 79 6e 63 |Note tha|t resync|
|00005810| 5f 74 6f 5f 72 65 73 74 | 61 72 74 20 69 73 20 4e |_to_rest|art is N|
|00005820| 4f 54 20 63 61 6c 6c 65 | 64 20 61 74 20 74 68 65 |OT calle|d at the|
|00005830| 20 65 6e 64 20 6f 66 20 | 61 20 73 63 61 6e 3b 0a | end of |a scan;.|
|00005840| 58 20 20 20 69 74 20 69 | 73 20 72 65 61 64 5f 73 |X it i|s read_s|
|00005850| 63 61 6e 5f 74 72 61 69 | 6c 65 72 27 73 20 72 65 |can_trai|ler's re|
|00005860| 73 70 6f 6e 73 69 62 69 | 6c 69 74 79 20 74 6f 20 |sponsibi|lity to |
|00005870| 72 65 73 79 6e 63 20 74 | 68 65 72 65 2e 0a 58 0a |resync t|here..X.|
|00005880| 58 20 20 20 4e 4f 54 45 | 3a 20 66 6f 72 20 4a 46 |X NOTE|: for JF|
|00005890| 49 46 2f 72 61 77 2d 4a | 50 45 47 20 66 69 6c 65 |IF/raw-J|PEG file|
|000058a0| 20 66 6f 72 6d 61 74 2c | 20 74 68 65 20 72 65 61 | format,| the rea|
|000058b0| 64 5f 6a 70 65 67 5f 64 | 61 74 61 20 72 6f 75 74 |d_jpeg_d|ata rout|
|000058c0| 69 6e 65 20 69 73 20 61 | 63 74 75 61 6c 6c 79 0a |ine is a|ctually.|
|000058d0| 58 20 20 20 73 75 70 70 | 6c 69 65 64 20 62 79 20 |X supp|lied by |
|000058e0| 74 68 65 20 75 73 65 72 | 20 69 6e 74 65 72 66 61 |the user| interfa|
|000058f0| 63 65 3b 20 74 68 65 20 | 6a 72 64 6a 66 69 66 20 |ce; the |jrdjfif |
|00005900| 6d 6f 64 75 6c 65 20 75 | 73 65 73 20 72 65 61 64 |module u|ses read|
|00005910| 5f 6a 70 65 67 5f 64 61 | 74 61 0a 58 20 20 20 69 |_jpeg_da|ta.X i|
|00005920| 6e 74 65 72 6e 61 6c 6c | 79 20 74 6f 20 73 63 61 |nternall|y to sca|
|00005930| 6e 20 74 68 65 20 69 6e | 70 75 74 20 73 74 72 65 |n the in|put stre|
|00005940| 61 6d 2e 20 20 54 68 69 | 73 20 6d 61 6b 65 73 20 |am. Thi|s makes |
|00005950| 69 74 20 70 6f 73 73 69 | 62 6c 65 20 66 6f 72 20 |it possi|ble for |
|00005960| 74 68 65 20 75 73 65 72 | 0a 58 20 20 20 69 6e 74 |the user|.X int|
|00005970| 65 72 66 61 63 65 20 6d | 6f 64 75 6c 65 20 74 6f |erface m|odule to|
|00005980| 20 73 69 6e 67 6c 65 2d | 68 61 6e 64 65 64 6c 79 | single-|handedly|
|00005990| 20 69 6d 70 6c 65 6d 65 | 6e 74 20 73 70 65 63 69 | impleme|nt speci|
|000059a0| 61 6c 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 20 |al appli|cations |
|000059b0| 6c 69 6b 65 0a 58 20 20 | 20 72 65 61 64 69 6e 67 |like.X | reading|
|000059c0| 20 66 72 6f 6d 20 61 20 | 6e 6f 6e 2d 73 74 64 69 | from a |non-stdi|
|000059d0| 6f 20 73 6f 75 72 63 65 | 2e 20 20 46 6f 72 20 4a |o source|. For J|
|000059e0| 50 45 47 2d 69 6e 2d 54 | 49 46 46 20 66 6f 72 6d |PEG-in-T|IFF form|
|000059f0| 61 74 2c 20 74 68 65 20 | 6e 65 65 64 20 66 6f 72 |at, the |need for|
|00005a00| 0a 58 20 20 20 72 61 6e | 64 6f 6d 20 61 63 63 65 |.X ran|dom acce|
|00005a10| 73 73 20 77 69 6c 6c 20 | 6d 61 6b 65 20 69 74 20 |ss will |make it |
|00005a20| 69 6d 70 6f 73 73 69 62 | 6c 65 20 66 6f 72 20 74 |impossib|le for t|
|00005a30| 68 69 73 20 74 6f 20 77 | 6f 72 6b 3b 20 68 65 6e |his to w|ork; hen|
|00005a40| 63 65 20 74 68 65 20 54 | 49 46 46 0a 58 20 20 20 |ce the T|IFF.X |
|00005a50| 68 65 61 64 65 72 20 6d | 6f 64 75 6c 65 20 77 69 |header m|odule wi|
|00005a60| 6c 6c 20 6f 76 65 72 72 | 69 64 65 20 74 68 65 20 |ll overr|ide the |
|00005a70| 55 49 2d 73 75 70 70 6c | 69 65 64 20 72 65 61 64 |UI-suppl|ied read|
|00005a80| 5f 6a 70 65 67 5f 64 61 | 74 61 20 72 6f 75 74 69 |_jpeg_da|ta routi|
|00005a90| 6e 65 2e 0a 58 20 20 20 | 4e 6f 6e 2d 73 74 64 69 |ne..X |Non-stdi|
|00005aa0| 6f 20 69 6e 70 75 74 20 | 66 72 6f 6d 20 61 20 54 |o input |from a T|
|00005ab0| 49 46 46 20 66 69 6c 65 | 20 77 69 6c 6c 20 72 65 |IFF file| will re|
|00005ac0| 71 75 69 72 65 20 65 78 | 74 65 6e 73 69 76 65 20 |quire ex|tensive |
|00005ad0| 73 75 72 67 65 72 79 20 | 74 6f 20 74 68 65 20 54 |surgery |to the T|
|00005ae0| 49 46 46 0a 58 20 20 20 | 68 65 61 64 65 72 20 6d |IFF.X |header m|
|00005af0| 6f 64 75 6c 65 2c 20 69 | 66 20 69 6e 64 65 65 64 |odule, i|f indeed|
|00005b00| 20 69 74 20 69 73 20 70 | 72 61 63 74 69 63 61 6c | it is p|ractical|
|00005b10| 20 61 74 20 61 6c 6c 2e | 0a 58 0a 58 32 2e 20 45 | at all.|.X.X2. E|
|00005b20| 6e 74 72 6f 70 79 20 28 | 48 75 66 66 6d 61 6e 20 |ntropy (|Huffman |
|00005b30| 6f 72 20 61 72 69 74 68 | 6d 65 74 69 63 29 20 64 |or arith|metic) d|
|00005b40| 65 63 6f 64 69 6e 67 20 | 6f 66 20 74 68 65 20 63 |ecoding |of the c|
|00005b50| 6f 65 66 66 69 63 69 65 | 6e 74 20 73 65 71 75 65 |oefficie|nt seque|
|00005b60| 6e 63 65 2e 0a 58 09 65 | 6e 74 72 6f 70 79 5f 64 |nce..X.e|ntropy_d|
|00005b70| 65 63 6f 64 65 5f 69 6e | 69 74 3a 20 70 72 65 70 |ecode_in|it: prep|
|00005b80| 61 72 65 20 66 6f 72 20 | 6f 6e 65 20 73 63 61 6e |are for |one scan|
|00005b90| 2e 0a 58 09 65 6e 74 72 | 6f 70 79 5f 64 65 63 6f |..X.entr|opy_deco|
|00005ba0| 64 65 3a 20 64 65 63 6f | 64 65 73 20 61 6e 64 20 |de: deco|des and |
|00005bb0| 72 65 74 75 72 6e 73 20 | 61 6e 20 4d 43 55 27 73 |returns |an MCU's|
|00005bc0| 20 77 6f 72 74 68 20 6f | 66 20 71 75 61 6e 74 69 | worth o|f quanti|
|00005bd0| 7a 65 64 0a 58 09 09 09 | 63 6f 65 66 66 69 63 69 |zed.X...|coeffici|
|00005be0| 65 6e 74 73 20 70 65 72 | 20 63 61 6c 6c 2e 0a 58 |ents per| call..X|
|00005bf0| 09 65 6e 74 72 6f 70 79 | 5f 64 65 63 6f 64 65 5f |.entropy|_decode_|
|00005c00| 74 65 72 6d 3a 20 66 69 | 6e 69 73 68 20 75 70 20 |term: fi|nish up |
|00005c10| 61 66 74 65 72 20 61 20 | 73 63 61 6e 20 28 6d 61 |after a |scan (ma|
|00005c20| 79 20 62 65 20 61 20 6e | 6f 2d 6f 70 29 2e 0a 58 |y be a n|o-op)..X|
|00005c30| 20 20 20 54 68 69 73 20 | 77 69 6c 6c 20 72 65 61 | This |will rea|
|00005c40| 64 20 72 61 77 20 64 61 | 74 61 20 62 79 20 63 61 |d raw da|ta by ca|
|00005c50| 6c 6c 69 6e 67 20 74 68 | 65 20 72 65 61 64 5f 6a |lling th|e read_j|
|00005c60| 70 65 67 5f 64 61 74 61 | 20 6d 65 74 68 6f 64 20 |peg_data| method |
|00005c70| 28 49 20 64 6f 6e 27 74 | 20 73 65 65 0a 58 20 20 |(I don't| see.X |
|00005c80| 20 61 6e 79 20 72 65 61 | 73 6f 6e 20 74 6f 20 70 | any rea|son to p|
|00005c90| 72 6f 76 69 64 65 20 61 | 20 66 75 72 74 68 65 72 |rovide a| further|
|00005ca0| 20 6c 65 76 65 6c 20 6f | 66 20 69 6e 64 69 72 65 | level o|f indire|
|00005cb0| 63 74 69 6f 6e 29 2e 0a | 58 20 20 20 28 54 68 69 |ction)..|X (Thi|
|00005cc0| 73 20 68 69 64 65 73 20 | 77 68 69 63 68 20 65 6e |s hides |which en|
|00005cd0| 74 72 6f 70 79 20 65 6e | 63 6f 64 69 6e 67 20 6d |tropy en|coding m|
|00005ce0| 65 74 68 6f 64 20 69 73 | 20 69 6e 20 75 73 65 2e |ethod is| in use.|
|00005cf0| 29 0a 58 0a 58 33 2e 20 | 51 75 61 6e 74 69 7a 61 |).X.X3. |Quantiza|
|00005d00| 74 69 6f 6e 20 64 65 73 | 63 61 6c 69 6e 67 20 61 |tion des|caling a|
|00005d10| 6e 64 20 7a 69 67 7a 61 | 67 20 72 65 6f 72 64 65 |nd zigza|g reorde|
|00005d20| 72 69 6e 67 20 6f 66 20 | 74 68 65 20 65 6c 65 6d |ring of |the elem|
|00005d30| 65 6e 74 73 20 69 6e 20 | 65 61 63 68 20 38 78 38 |ents in |each 8x8|
|00005d40| 0a 58 20 20 20 62 6c 6f | 63 6b 2e 20 20 54 68 69 |.X blo|ck. Thi|
|00005d50| 73 20 77 69 6c 6c 20 62 | 65 20 66 6f 6c 64 65 64 |s will b|e folded|
|00005d60| 20 69 6e 74 6f 20 65 6e | 74 72 6f 70 79 5f 64 65 | into en|tropy_de|
|00005d70| 63 6f 64 65 20 66 6f 72 | 20 65 66 66 69 63 69 65 |code for| efficie|
|00005d80| 6e 63 79 20 72 65 61 73 | 6f 6e 73 3a 0a 58 20 20 |ncy reas|ons:.X |
|00005d90| 20 6d 61 6e 79 20 6f 66 | 20 74 68 65 20 63 6f 65 | many of| the coe|
|00005da0| 66 66 69 63 69 65 6e 74 | 73 20 61 72 65 20 7a 65 |fficient|s are ze|
|00005db0| 72 6f 65 73 2c 20 61 6e | 64 20 74 68 69 73 20 63 |roes, an|d this c|
|00005dc0| 61 6e 20 62 65 20 65 78 | 70 6c 6f 69 74 65 64 20 |an be ex|ploited |
|00005dd0| 6d 6f 73 74 20 65 61 73 | 69 6c 79 0a 58 20 20 20 |most eas|ily.X |
|00005de0| 77 69 74 68 69 6e 20 65 | 6e 74 72 6f 70 79 5f 64 |within e|ntropy_d|
|00005df0| 65 63 6f 64 65 20 73 69 | 6e 63 65 20 74 68 65 20 |ecode si|nce the |
|00005e00| 65 6e 63 6f 64 69 6e 67 | 20 65 78 70 6c 69 63 69 |encoding| explici|
|00005e10| 74 6c 79 20 73 6b 69 70 | 73 20 7a 65 72 6f 65 73 |tly skip|s zeroes|
|00005e20| 2e 0a 58 0a 58 34 2e 20 | 4d 43 55 20 64 69 73 61 |..X.X4. |MCU disa|
|00005e30| 73 73 65 6d 62 6c 79 20 | 28 63 6f 6e 76 65 72 73 |ssembly |(convers|
|00005e40| 69 6f 6e 20 6f 66 20 61 | 20 70 6f 73 73 69 62 6c |ion of a| possibl|
|00005e50| 79 20 69 6e 74 65 72 6c | 65 61 76 65 64 20 73 65 |y interl|eaved se|
|00005e60| 71 75 65 6e 63 65 20 6f | 66 20 38 78 38 0a 58 20 |quence o|f 8x8.X |
|00005e70| 20 20 62 6c 6f 63 6b 73 | 20 62 61 63 6b 20 74 6f | blocks| back to|
|00005e80| 20 73 65 70 61 72 61 74 | 65 20 63 6f 6d 70 6f 6e | separat|e compon|
|00005e90| 65 6e 74 73 20 69 6e 20 | 70 69 78 65 6c 20 6d 61 |ents in |pixel ma|
|00005ea0| 70 20 6f 72 64 65 72 29 | 2e 0a 58 09 64 69 73 61 |p order)|..X.disa|
|00005eb0| 73 73 65 6d 62 6c 65 5f | 69 6e 69 74 3a 20 69 6e |ssemble_|init: in|
|00005ec0| 69 74 69 61 6c 69 7a 65 | 2e 20 20 54 68 69 73 20 |itialize|. This |
|00005ed0| 77 69 6c 6c 20 62 65 20 | 63 61 6c 6c 65 64 20 6f |will be |called o|
|00005ee0| 6e 63 65 20 70 65 72 20 | 73 63 61 6e 2e 0a 58 09 |nce per |scan..X.|
|00005ef0| 64 69 73 61 73 73 65 6d | 62 6c 65 5f 4d 43 55 3a |disassem|ble_MCU:|
|00005f00| 20 20 47 69 76 65 6e 20 | 61 6e 20 4d 43 55 27 73 | Given |an MCU's|
|00005f10| 20 77 6f 72 74 68 20 6f | 66 20 64 65 71 75 61 6e | worth o|f dequan|
|00005f20| 74 69 7a 65 64 20 62 6c | 6f 63 6b 73 2c 0a 58 09 |tized bl|ocks,.X.|
|00005f30| 09 09 20 20 64 69 73 74 | 72 69 62 75 74 65 20 74 |.. dist|ribute t|
|00005f40| 68 65 6d 20 69 6e 74 6f | 20 74 68 65 20 70 72 6f |hem into| the pro|
|00005f50| 70 65 72 20 6c 6f 63 61 | 74 69 6f 6e 73 20 69 6e |per loca|tions in|
|00005f60| 20 61 0a 58 09 09 09 20 | 20 63 6f 65 66 66 69 63 | a.X... | coeffic|
|00005f70| 69 65 6e 74 20 69 6d 61 | 67 65 20 61 72 72 61 79 |ient ima|ge array|
|00005f80| 2e 0a 58 09 64 69 73 61 | 73 73 65 6d 62 6c 65 5f |..X.disa|ssemble_|
|00005f90| 74 65 72 6d 3a 20 63 6c | 65 61 6e 20 75 70 20 61 |term: cl|ean up a|
|00005fa0| 74 20 74 68 65 20 65 6e | 64 20 6f 66 20 61 20 73 |t the en|d of a s|
|00005fb0| 63 61 6e 2e 0a 58 20 20 | 20 50 72 6f 62 61 62 6c |can..X | Probabl|
|00005fc0| 79 20 74 68 69 73 20 73 | 68 6f 75 6c 64 20 62 65 |y this s|hould be|
|00005fd0| 20 63 61 6c 6c 65 64 20 | 6f 6e 63 65 20 70 65 72 | called |once per|
|00005fe0| 20 4d 43 55 20 72 6f 77 | 20 61 6e 64 20 73 68 6f | MCU row| and sho|
|00005ff0| 75 6c 64 20 63 61 6c 6c | 20 74 68 65 0a 58 20 20 |uld call| the.X |
|00006000| 20 65 6e 74 72 6f 70 79 | 20 64 65 63 6f 64 65 72 | entropy| decoder|
|00006010| 20 72 65 70 65 61 74 65 | 64 6c 79 20 74 6f 20 6f | repeate|dly to o|
|00006020| 62 74 61 69 6e 20 74 68 | 65 20 72 6f 77 27 73 20 |btain th|e row's |
|00006030| 64 61 74 61 2e 20 20 54 | 68 65 20 6f 75 74 70 75 |data. T|he outpu|
|00006040| 74 20 69 73 0a 58 20 20 | 20 61 6c 77 61 79 73 20 |t is.X | always |
|00006050| 61 20 6d 75 6c 74 69 70 | 6c 65 20 6f 66 20 61 6e |a multip|le of an|
|00006060| 20 4d 43 55 27 73 20 64 | 69 6d 65 6e 73 69 6f 6e | MCU's d|imension|
|00006070| 73 2e 0a 58 20 20 20 28 | 41 6e 20 6f 62 6a 65 63 |s..X (|An objec|
|00006080| 74 20 6f 6e 20 74 68 65 | 20 67 72 6f 75 6e 64 73 |t on the| grounds|
|00006090| 20 74 68 61 74 20 6d 75 | 6c 74 69 70 6c 65 20 69 | that mu|ltiple i|
|000060a0| 6e 73 74 61 6e 74 69 61 | 74 69 6f 6e 73 20 6d 69 |nstantia|tions mi|
|000060b0| 67 68 74 20 62 65 20 75 | 73 65 66 75 6c 2e 29 0a |ght be u|seful.).|
|000060c0| 58 0a 58 35 2e 20 43 72 | 6f 73 73 2d 62 6c 6f 63 |X.X5. Cr|oss-bloc|
|000060d0| 6b 20 73 6d 6f 6f 74 68 | 69 6e 67 20 70 65 72 20 |k smooth|ing per |
|000060e0| 4a 50 45 47 20 73 65 63 | 74 69 6f 6e 20 4b 2e 38 |JPEG sec|tion K.8|
|000060f0| 20 6f 72 20 61 20 73 69 | 6d 69 6c 61 72 20 61 6c | or a si|milar al|
|00006100| 67 6f 72 69 74 68 6d 2e | 0a 58 09 73 6d 6f 6f 74 |gorithm.|.X.smoot|
|00006110| 68 5f 63 6f 65 66 66 69 | 63 69 65 6e 74 73 3a 20 |h_coeffi|cients: |
|00006120| 47 69 76 65 6e 20 74 68 | 72 65 65 20 62 6c 6f 63 |Given th|ree bloc|
|00006130| 6b 20 72 6f 77 73 27 20 | 77 6f 72 74 68 20 6f 66 |k rows' |worth of|
|00006140| 20 61 20 73 69 6e 67 6c | 65 0a 58 09 09 09 20 20 | a singl|e.X... |
|00006150| 20 20 20 63 6f 6d 70 6f | 6e 65 6e 74 2c 20 65 6d | compo|nent, em|
|00006160| 69 74 20 61 20 73 6d 6f | 6f 74 68 65 64 20 65 71 |it a smo|othed eq|
|00006170| 75 69 76 61 6c 65 6e 74 | 20 6f 66 20 74 68 65 0a |uivalent| of the.|
|00006180| 58 09 09 09 20 20 20 20 | 20 6d 69 64 64 6c 65 20 |X... | middle |
|00006190| 72 6f 77 2e 20 20 54 68 | 65 20 22 61 62 6f 76 65 |row. Th|e "above|
|000061a0| 22 20 61 6e 64 20 22 62 | 65 6c 6f 77 22 20 70 6f |" and "b|elow" po|
|000061b0| 69 6e 74 65 72 73 0a 58 | 09 09 09 20 20 20 20 20 |inters.X|... |
|000061c0| 6d 61 79 20 62 65 20 4e | 55 4c 4c 20 69 66 20 61 |may be N|ULL if a|
|000061d0| 74 20 74 6f 70 2f 62 6f | 74 74 6f 6d 20 6f 66 20 |t top/bo|ttom of |
|000061e0| 69 6d 61 67 65 2e 0a 58 | 20 20 20 54 68 65 20 70 |image..X| The p|
|000061f0| 69 70 65 6c 69 6e 65 20 | 63 6f 6e 74 72 6f 6c 6c |ipeline |controll|
|00006200| 65 72 20 77 69 6c 6c 20 | 64 6f 20 74 68 65 20 6e |er will |do the n|
|00006210| 65 63 65 73 73 61 72 79 | 20 62 75 66 66 65 72 69 |ecessary| bufferi|
|00006220| 6e 67 20 74 6f 20 70 72 | 6f 76 69 64 65 20 74 68 |ng to pr|ovide th|
|00006230| 65 0a 58 20 20 20 61 62 | 6f 76 65 2f 62 65 6c 6f |e.X ab|ove/belo|
|00006240| 77 20 63 6f 6e 74 65 78 | 74 2e 20 20 53 6d 6f 6f |w contex|t. Smoo|
|00006250| 74 68 69 6e 67 20 77 69 | 6c 6c 20 62 65 20 6f 70 |thing wi|ll be op|
|00006260| 74 69 6f 6e 61 6c 20 73 | 69 6e 63 65 20 61 20 67 |tional s|ince a g|
|00006270| 6f 6f 64 20 64 65 61 6c | 20 6f 66 0a 58 20 20 20 |ood deal| of.X |
|00006280| 65 78 74 72 61 20 6d 65 | 6d 6f 72 79 20 69 73 20 |extra me|mory is |
|00006290| 6e 65 65 64 65 64 20 74 | 6f 20 62 75 66 66 65 72 |needed t|o buffer|
|000062a0| 20 74 68 65 20 61 64 64 | 69 74 69 6f 6e 61 6c 20 | the add|itional |
|000062b0| 62 6c 6f 63 6b 20 72 6f | 77 73 2e 0a 58 20 20 20 |block ro|ws..X |
|000062c0| 28 54 68 69 73 20 6f 62 | 6a 65 63 74 20 68 69 64 |(This ob|ject hid|
|000062d0| 65 73 20 74 68 65 20 64 | 65 74 61 69 6c 73 20 6f |es the d|etails o|
|000062e0| 66 20 74 68 65 20 73 6d | 6f 6f 74 68 69 6e 67 20 |f the sm|oothing |
|000062f0| 61 6c 67 6f 72 69 74 68 | 6d 2e 29 0a 58 0a 58 36 |algorith|m.).X.X6|
|00006300| 2e 20 49 6e 76 65 72 73 | 65 20 44 43 54 20 74 72 |. Invers|e DCT tr|
|00006310| 61 6e 73 66 6f 72 6d 61 | 74 69 6f 6e 20 6f 66 20 |ansforma|tion of |
|00006320| 65 61 63 68 20 38 78 38 | 20 62 6c 6f 63 6b 2e 0a |each 8x8| block..|
|00006330| 58 09 72 65 76 65 72 73 | 65 5f 44 43 54 3a 20 67 |X.revers|e_DCT: g|
|00006340| 69 76 65 6e 20 61 6e 20 | 4d 43 55 20 72 6f 77 27 |iven an |MCU row'|
|00006350| 73 20 77 6f 72 74 68 20 | 6f 66 20 62 6c 6f 63 6b |s worth |of block|
|00006360| 73 2c 20 70 65 72 66 6f | 72 6d 20 69 6e 76 65 72 |s, perfo|rm inver|
|00006370| 73 65 0a 58 09 09 20 20 | 20 20 20 44 43 54 20 6f |se.X.. | DCT o|
|00006380| 6e 20 65 61 63 68 20 62 | 6c 6f 63 6b 20 61 6e 64 |n each b|lock and|
|00006390| 20 6f 75 74 70 75 74 20 | 74 68 65 20 72 65 73 75 | output |the resu|
|000063a0| 6c 74 73 20 69 6e 74 6f | 20 61 6e 20 61 72 72 61 |lts into| an arra|
|000063b0| 79 0a 58 09 09 20 20 20 | 20 20 6f 66 20 73 61 6d |y.X.. | of sam|
|000063c0| 70 6c 65 73 2e 0a 58 20 | 20 20 57 65 20 70 75 74 |ples..X | We put|
|000063d0| 20 74 68 69 73 20 6d 65 | 74 68 6f 64 20 69 6e 74 | this me|thod int|
|000063e0| 6f 20 74 68 65 20 6a 64 | 6d 63 75 20 6d 6f 64 75 |o the jd|mcu modu|
|000063f0| 6c 65 20 66 6f 72 20 73 | 79 6d 6d 65 74 72 79 20 |le for s|ymmetry |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.