2013年1月12日 星期六

98360915 資工四甲 周立祥

  本次作業著重於分析jpeg影像的header,但可惜的是,由於忘記該如何利用各張table來decode存放在scan header後方的data,因此本次作業範圍缺失了decode這部分。
  另外,由於目前使用之作業系統已無windows,因此這次作業是單純使用C++撰寫完成,首先先看這次的開發過程,如下圖:

圖一

  以下是成品之執行狀態,如下圖:

圖二

  由圖一可了解到huffman tree每個節點的結構以及各個資料的存放陣列,而接下來先展示分析老師課堂教學圖片(Rex.jpg)之資訊,如下:

圖三

start: ffd8

marker: ffe0 length: 010
Application Segments

marker: ffe1 length: ee1
Application Segments

marker: ffed length: 139a
Application Segments

marker: ffe1 length: 1248
Application Segments

marker: ffee length: 0e
Application Segments

marker: ffdb length: 084
Quantization Table:
 element precision: 0
 destination id: 0
 elements: 2 2 2 2 2 2 2 2 2 2 3 2 2 2 3 4 3 2 2 3 4 5 4 4 4 4 4 5 6 5 5 5 5 5 5 6 6 7 7 8 7 7 6 9 9 10 10 9 9 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 

Quantization Table:
 element precision: 0
 destination id: 1
 elements: 3 3 3 5 4 5 9 6 6 9 13 10 9 10 13 15 14 14 14 14 15 15 12 12 12 12 12 15 15 12 12 12 12 12 12 15 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 

marker: ffc0 length: 011
Frame Header:
 type: Baseline DCT
 sample precision: 8 bits
 height: 120 pixels
 width: 120 pixels
 image components: 3
-The 1 Component:
  component id: 1
  horizontal sampling factor: 1
  vertical sampling factor: 1
  quantization table: 0
-The 2 Component:
  component id: 2
  horizontal sampling factor: 1
  vertical sampling factor: 1
  quantization table: 1
-The 3 Component:
  component id: 3
  horizontal sampling factor: 1
  vertical sampling factor: 1
  quantization table: 1

marker: ffdd length: 04
Restart Interval:
 MCU restart interval: f

marker: ffc4 length: 1a2
Huffman Table: 
 tc: 0 th: 0  (DC Table)
 bits:  0 0 7 1 1 1 1 1 0 0 0 0 0 0 0 0 
-Before Value Ordering:
  size:  3 3 3 3 3 3 3 4 5 6 7 8 
  value: 4 5 3 2 6 1 0 7 8 9 a b 
  code:  0 1 2 3 4 5 6 14 30 62 126 254 
-After Value Ordering:
  size:  3 3 3 3 3 3 3 4 5 6 7 8 
  value: 0 1 2 3 4 5 6 7 8 9 a b 
  code:  6 5 3 2 0 1 4 14 30 62 126 254 

Huffman Table: 
 tc: 0 th: 1  (DC Table)
 bits:  0 2 2 3 1 1 1 1 1 0 0 0 0 0 0 0 
-Before Value Ordering:
  size:  2 2 3 3 4 4 4 5 6 7 8 9 
  value: 1 0 2 3 4 5 6 7 8 9 a b 
  code:  0 1 4 5 12 13 14 30 62 126 254 510 
-After Value Ordering:
  size:  2 2 3 3 4 4 4 5 6 7 8 9 
  value: 0 1 2 3 4 5 6 7 8 9 a b 
  code:  1 0 4 5 12 13 14 30 62 126 254 510 

Huffman Table: 
 tc: 1 th: 0  (AC Table)
 bits:  0 2 1 3 3 2 4 2 6 7 3 4 2 6 2 73 
-Before Value Ordering:
  size:  2 2 3 4 4 4 5 5 5 6 6 7 7 7 7 8 8 9 9 9 9 9 9 10 10 10 10 10 10 10 11 11 11 12 12 12 12 13 13 14 14 14 14 14 14 15 15 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 
  value: 0/1 0/2 0/3 1/1 0/4 0/0 0/5 2/1 1/2 3/1 4/1 5/1 0/6 1/3 6/1 2/2 7/1 8/1 1/4 3/2 9/1 a/1 0/7 1/5 b/1 4/2 2/3 c/1 5/2 d/1 e/1 3/3 1/6 6/2 f/0 2/4 7/2 8/2 f/1 2/5 4/3 3/4 5/3 9/2 a/2 b/2 6/3 7/3 c/2 3/5 4/4 2/7 9/3 a/3 b/3 3/6 1/7 5/4 6/4 7/4 c/3 d/2 e/2 0/8 2/6 8/3 0/9 0/a 1/8 1/9 8/4 9/4 4/5 4/6 a/4 b/4 5/6 d/3 5/5 2/8 1/a f/2 e/3 f/3 c/4 d/4 e/4 f/4 6/5 7/5 8/5 9/5 a/5 b/5 c/5 d/5 e/5 f/5 6/6 7/6 8/6 9/6 a/6 b/6 c/6 d/6 e/6 f/6 3/7 4/7 5/7 6/7 7/7 8/7 9/7 a/7 b/7 c/7 d/7 e/7 f/7 3/8 4/8 5/8 6/8 7/8 8/8 9/8 a/8 b/8 c/8 d/8 e/8 f/8 2/9 3/9 4/9 5/9 6/9 7/9 8/9 9/9 a/9 b/9 c/9 d/9 e/9 f/9 2/a 3/a 4/a 5/a 6/a 7/a 8/a 9/a a/a b/a c/a d/a e/a f/a 
  code:  0 1 4 10 11 12 26 27 28 58 59 120 121 122 123 248 249 500 501 502 503 504 505 1012 1013 1014 1015 1016 1017 1018 2038 2039 2040 4082 4083 4084 4085 8172 8173 16348 16349 16350 16351 16352 16353 32708 32709 65420 65421 65422 65423 65424 65425 65426 65427 65428 65429 65430 65431 65432 65433 65434 65435 65436 65437 65438 65439 65440 65441 65442 65443 65444 65445 65446 65447 65448 65449 65450 65451 65452 65453 65454 65455 65456 65457 65458 65459 65460 65461 65462 65463 65464 65465 65466 65467 65468 65469 65470 65471 65472 65473 65474 65475 65476 65477 65478 65479 65480 65481 65482 65483 65484 65485 65486 65487 65488 65489 65490 65491 65492 65493 65494 65495 65496 65497 65498 65499 65500 65501 65502 65503 65504 65505 65506 65507 65508 65509 65510 65511 65512 65513 65514 65515 65516 65517 65518 65519 65520 65521 65522 65523 65524 65525 65526 65527 65528 65529 65530 65531 65532 65533 65534 
-After Value Ordering:
  size:  4 2 2 3 4 5 7 9 16 16 16 4 5 7 9 10 11 16 16 16 16 5 8 10 12 14 16 16 16 16 16 6 9 11 14 16 16 16 16 16 16 6 10 14 16 16 16 16 16 16 16 7 10 14 16 16 16 16 16 16 16 7 12 15 16 16 16 16 16 16 16 8 12 16 16 16 16 16 16 16 16 9 13 16 16 16 16 16 16 16 16 9 14 16 16 16 16 16 16 16 16 9 14 16 16 16 16 16 16 16 16 10 15 16 16 16 16 16 16 16 16 10 16 16 16 16 16 16 16 16 16 10 16 16 16 16 16 16 16 16 16 11 16 16 16 16 16 16 16 16 16 12 13 16 16 16 16 16 16 16 16 16 
  value: 0/0 0/1 0/2 0/3 0/4 0/5 0/6 0/7 0/8 0/9 0/a 1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 1/a 2/1 2/2 2/3 2/4 2/5 2/6 2/7 2/8 2/9 2/a 3/1 3/2 3/3 3/4 3/5 3/6 3/7 3/8 3/9 3/a 4/1 4/2 4/3 4/4 4/5 4/6 4/7 4/8 4/9 4/a 5/1 5/2 5/3 5/4 5/5 5/6 5/7 5/8 5/9 5/a 6/1 6/2 6/3 6/4 6/5 6/6 6/7 6/8 6/9 6/a 7/1 7/2 7/3 7/4 7/5 7/6 7/7 7/8 7/9 7/a 8/1 8/2 8/3 8/4 8/5 8/6 8/7 8/8 8/9 8/a 9/1 9/2 9/3 9/4 9/5 9/6 9/7 9/8 9/9 9/a a/1 a/2 a/3 a/4 a/5 a/6 a/7 a/8 a/9 a/a b/1 b/2 b/3 b/4 b/5 b/6 b/7 b/8 b/9 b/a c/1 c/2 c/3 c/4 c/5 c/6 c/7 c/8 c/9 c/a d/1 d/2 d/3 d/4 d/5 d/6 d/7 d/8 d/9 d/a e/1 e/2 e/3 e/4 e/5 e/6 e/7 e/8 e/9 e/a f/0 f/1 f/2 f/3 f/4 f/5 f/6 f/7 f/8 f/9 f/a 
  code:  12 0 1 4 11 26 121 505 65436 65439 65440 10 28 122 501 1012 2040 65429 65441 65442 65453 27 248 1015 4084 16348 65437 65424 65452 65507 65521 58 502 2039 16350 65422 65428 65481 65494 65508 65522 59 1014 16349 65423 65445 65446 65482 65495 65509 65523 120 1017 16351 65430 65451 65449 65483 65496 65510 65524 123 4082 32709 65431 65461 65471 65484 65497 65511 65525 249 4085 65420 65432 65462 65472 65485 65498 65512 65526 500 8172 65438 65443 65463 65473 65486 65499 65513 65527 503 16352 65425 65444 65464 65474 65487 65500 65514 65528 504 16353 65426 65447 65465 65475 65488 65501 65515 65529 1013 32708 65427 65448 65466 65476 65489 65502 65516 65530 1016 65421 65433 65457 65467 65477 65490 65503 65517 65531 1018 65434 65450 65458 65468 65478 65491 65504 65518 65532 2038 65435 65455 65459 65469 65479 65492 65505 65519 65533 4083 8173 65454 65456 65460 65470 65480 65493 65506 65520 65534 

Huffman Table: 
 tc: 1 th: 1  (AC Table)
 bits:  0 2 2 1 2 3 5 5 4 5 6 4 8 3 3 6d 
-Before Value Ordering:
  size:  2 2 3 3 4 5 5 6 6 6 7 7 7 7 7 8 8 8 8 8 9 9 9 9 10 10 10 10 10 11 11 11 11 11 11 12 12 12 12 13 13 13 13 13 13 13 13 14 14 14 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 
  value: 0/1 0/0 0/2 1/1 0/3 0/4 2/1 1/2 3/1 4/1 0/5 5/1 1/3 6/1 2/2 0/6 7/1 8/1 9/1 3/2 a/1 b/1 f/0 1/4 c/1 d/1 e/1 2/3 4/2 1/5 5/2 6/2 7/2 f/1 3/3 2/4 3/4 4/3 8/2 1/6 9/2 5/3 2/5 a/2 6/3 b/2 c/2 0/7 7/3 d/2 3/5 e/2 4/4 8/3 1/7 5/4 9/3 0/8 0/9 0/a 1/8 1/9 2/6 3/6 4/5 1/a 2/7 6/4 7/4 5/5 3/7 f/2 a/3 b/3 c/3 2/8 2/9 d/3 e/3 f/3 8/4 9/4 a/4 b/4 c/4 d/4 e/4 f/4 6/5 7/5 8/5 9/5 a/5 b/5 c/5 d/5 e/5 f/5 4/6 5/6 6/6 7/6 8/6 9/6 a/6 b/6 c/6 d/6 e/6 f/6 4/7 5/7 6/7 7/7 8/7 9/7 a/7 b/7 c/7 d/7 e/7 f/7 3/8 4/8 5/8 6/8 7/8 8/8 9/8 a/8 b/8 c/8 d/8 e/8 f/8 3/9 4/9 5/9 6/9 7/9 8/9 9/9 a/9 b/9 c/9 d/9 e/9 f/9 2/a 3/a 4/a 5/a 6/a 7/a 8/a 9/a a/a b/a c/a d/a e/a f/a 
  code:  0 1 4 5 12 26 27 56 57 58 118 119 120 121 122 246 247 248 249 250 502 503 504 505 1012 1013 1014 1015 1016 2034 2035 2036 2037 2038 2039 4080 4081 4082 4083 8168 8169 8170 8171 8172 8173 8174 8175 16352 16353 16354 32710 32711 32712 65426 65427 65428 65429 65430 65431 65432 65433 65434 65435 65436 65437 65438 65439 65440 65441 65442 65443 65444 65445 65446 65447 65448 65449 65450 65451 65452 65453 65454 65455 65456 65457 65458 65459 65460 65461 65462 65463 65464 65465 65466 65467 65468 65469 65470 65471 65472 65473 65474 65475 65476 65477 65478 65479 65480 65481 65482 65483 65484 65485 65486 65487 65488 65489 65490 65491 65492 65493 65494 65495 65496 65497 65498 65499 65500 65501 65502 65503 65504 65505 65506 65507 65508 65509 65510 65511 65512 65513 65514 65515 65516 65517 65518 65519 65520 65521 65522 65523 65524 65525 65526 65527 65528 65529 65530 65531 65532 65533 65534 
-After Value Ordering:
  size:  2 2 3 4 5 7 8 14 16 16 16 3 6 7 9 11 13 16 16 16 16 5 7 10 12 13 16 16 16 16 16 6 8 11 12 15 16 16 16 16 16 6 10 12 15 16 16 16 16 16 16 7 11 13 16 16 16 16 16 16 16 7 11 13 16 16 16 16 16 16 16 8 11 14 16 16 16 16 16 16 16 8 12 16 16 16 16 16 16 16 16 8 13 16 16 16 16 16 16 16 16 9 13 16 16 16 16 16 16 16 16 9 13 16 16 16 16 16 16 16 16 10 13 16 16 16 16 16 16 16 16 10 14 16 16 16 16 16 16 16 16 10 15 16 16 16 16 16 16 16 16 9 11 16 16 16 16 16 16 16 16 16 
  value: 0/0 0/1 0/2 0/3 0/4 0/5 0/6 0/7 0/8 0/9 0/a 1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 1/a 2/1 2/2 2/3 2/4 2/5 2/6 2/7 2/8 2/9 2/a 3/1 3/2 3/3 3/4 3/5 3/6 3/7 3/8 3/9 3/a 4/1 4/2 4/3 4/4 4/5 4/6 4/7 4/8 4/9 4/a 5/1 5/2 5/3 5/4 5/5 5/6 5/7 5/8 5/9 5/a 6/1 6/2 6/3 6/4 6/5 6/6 6/7 6/8 6/9 6/a 7/1 7/2 7/3 7/4 7/5 7/6 7/7 7/8 7/9 7/a 8/1 8/2 8/3 8/4 8/5 8/6 8/7 8/8 8/9 8/a 9/1 9/2 9/3 9/4 9/5 9/6 9/7 9/8 9/9 9/a a/1 a/2 a/3 a/4 a/5 a/6 a/7 a/8 a/9 a/a b/1 b/2 b/3 b/4 b/5 b/6 b/7 b/8 b/9 b/a c/1 c/2 c/3 c/4 c/5 c/6 c/7 c/8 c/9 c/a d/1 d/2 d/3 d/4 d/5 d/6 d/7 d/8 d/9 d/a e/1 e/2 e/3 e/4 e/5 e/6 e/7 e/8 e/9 e/a f/0 f/1 f/2 f/3 f/4 f/5 f/6 f/7 f/8 f/9 f/a 
  code:  1 0 4 12 26 118 246 16352 65430 65431 65432 5 56 120 505 2034 8168 65427 65433 65434 65438 27 122 1015 4080 8171 65435 65439 65448 65449 65521 57 250 2039 4081 32710 65436 65443 65495 65508 65522 58 1016 4082 32712 65437 65471 65483 65496 65509 65523 119 2035 8170 65428 65442 65472 65484 65497 65510 65524 121 2036 8173 65440 65461 65473 65485 65498 65511 65525 247 2037 16353 65441 65462 65474 65486 65499 65512 65526 248 4083 65426 65453 65463 65475 65487 65500 65513 65527 249 8169 65429 65454 65464 65476 65488 65501 65514 65528 502 8172 65445 65455 65465 65477 65489 65502 65515 65529 503 8174 65446 65456 65466 65478 65490 65503 65516 65530 1012 8175 65447 65457 65467 65479 65491 65504 65517 65531 1013 16354 65450 65458 65468 65480 65492 65505 65518 65532 1014 32711 65451 65459 65469 65481 65493 65506 65519 65533 504 2038 65444 65452 65460 65470 65482 65494 65507 65520 65534 

marker: ffda length: 0c
Scan Header:
 image components: 3
-The 1 Component:
  scan component: 1
  dc table: 0
  ac table: 0
-The 2 Component:
  scan component: 2
  dc table: 1
  ac table: 1
-The 3 Component:
  scan component: 3
  dc table: 1
  ac table: 1
 start of spectral: 0
 end of spectral: 63
 approximation high: 0
 approximation low: 0

  接著我們來分析這次我所利用之圖片,如下:

圖四

start: ffd8

marker: ffe0 length: 010
Application Segments

marker: ffe1 length: 060
Application Segments

marker: ffdb length: 084
Quantization Table:
 element precision: 0
 destination id: 0
 elements: 3 2 2 3 2 2 3 3 3 3 4 3 3 4 5 8 5 5 4 4 5 10 7 7 6 8 12 10 12 12 11 10 11 11 13 14 18 16 13 14 17 14 11 11 16 22 16 16 19 28 28 21 21 12 15 23 24 22 20 24 29 20 27 14 

Quantization Table:
 element precision: 0
 destination id: 1
 elements: 3 4 4 6 5 6 10 6 6 10 15 14 12 14 14 16 16 16 15 14 13 14 14 12 14 13 17 14 15 16 13 12 18 15 15 15 13 13 14 12 14 16 12 15 16 12 13 13 13 13 13 12 16 12 15 13 12 13 13 15 12 13 12 13 

marker: ffc0 length: 011
Frame Header:
 type: Baseline DCT
 sample precision: 8 bits
 height: 44 pixels
 width: 44 pixels
 image components: 3
-The 1 Component:
  component id: 1
  horizontal sampling factor: 1
  vertical sampling factor: 1
  quantization table: 0
-The 2 Component:
  component id: 2
  horizontal sampling factor: 1
  vertical sampling factor: 1
  quantization table: 1
-The 3 Component:
  component id: 3
  horizontal sampling factor: 1
  vertical sampling factor: 1
  quantization table: 1

marker: ffc4 length: 01a
Huffman Table: 
 tc: 0 th: 0  (DC Table)
 bits:  0 3 1 1 1 1 0 0 0 0 0 0 0 0 0 0 
-Before Value Ordering:
  size:  2 2 2 3 4 5 6 
  value: 5 6 7 8 4 3 0 
  code:  0 1 2 6 14 30 62 
-After Value Ordering:
  size:  6 5 4 2 2 2 3 
  value: 0 3 4 5 6 7 8 
  code:  62 30 14 0 1 2 6 

marker: ffc4 length: 036
Huffman Table: 
 tc: 1 th: 0  (AC Table)
 bits:  0 1 3 2 4 5 2 4 1 d 0 0 0 0 0 0 
-Before Value Ordering:
  size:  2 3 3 3 4 4 5 5 5 5 6 6 6 6 6 7 7 8 8 8 8 9 10 10 10 10 10 10 10 10 10 10 10 10 10 
  value: 0/1 0/2 0/3 0/4 0/5 1/1 0/0 0/6 1/2 2/1 0/7 1/3 2/2 3/1 4/1 5/1 6/1 2/3 3/2 8/1 9/1 1/4 0/8 1/5 1/7 4/2 4/3 5/2 7/1 8/2 a/2 b/1 c/1 d/2 f/0 
  code:  0 2 3 4 10 11 24 25 26 27 56 57 58 59 60 122 123 248 249 250 251 504 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 
-After Value Ordering:
  size:  5 2 3 3 3 4 5 6 10 4 5 6 9 10 10 5 6 8 6 8 6 10 10 7 10 7 10 8 10 8 10 10 10 10 10 
  value: 0/0 0/1 0/2 0/3 0/4 0/5 0/6 0/7 0/8 1/1 1/2 1/3 1/4 1/5 1/7 2/1 2/2 2/3 3/1 3/2 4/1 4/2 4/3 5/1 5/2 6/1 7/1 8/1 8/2 9/1 a/2 b/1 c/1 d/2 f/0 
  code:  24 0 2 3 4 10 25 56 1010 11 26 57 504 1011 1012 27 58 248 59 249 60 1013 1014 122 1015 123 1016 250 1017 251 1018 1019 1020 1021 1022 

marker: ffc4 length: 01a
Huffman Table: 
 tc: 0 th: 1  (DC Table)
 bits:  0 2 3 1 1 0 0 0 0 0 0 0 0 0 0 0 
-Before Value Ordering:
  size:  2 2 3 3 3 4 5 
  value: 4 5 2 3 6 0 1 
  code:  0 1 4 5 6 14 30 
-After Value Ordering:
  size:  4 5 3 3 2 2 3 
  value: 0 1 2 3 4 5 6 
  code:  14 30 4 5 0 1 6 

marker: ffc4 length: 02a
Huffman Table: 
 tc: 1 th: 1  (AC Table)
 bits:  0 1 4 0 4 4 6 3 1 0 0 0 0 0 0 0 
-Before Value Ordering:
  size:  2 3 3 3 3 5 5 5 5 6 6 6 6 7 7 7 7 7 7 8 8 8 9 
  value: 0/1 0/0 0/2 0/3 1/1 0/4 1/2 2/1 5/1 0/5 1/3 3/1 4/1 8/1 9/1 a/1 b/1 d/1 f/0 6/1 7/1 c/1 2/3 
  code:  0 2 3 4 5 12 13 14 15 32 33 34 35 72 73 74 75 76 77 156 157 158 318 
-After Value Ordering:
  size:  3 2 3 3 5 6 3 5 6 5 9 6 6 5 8 8 7 7 7 7 8 7 7 
  value: 0/0 0/1 0/2 0/3 0/4 0/5 1/1 1/2 1/3 2/1 2/3 3/1 4/1 5/1 6/1 7/1 8/1 9/1 a/1 b/1 c/1 d/1 f/0 
  code:  2 0 3 4 12 32 5 13 33 14 318 34 35 15 156 157 72 73 74 75 158 76 77 

marker: ffda length: 0c
Scan Header:
 image components: 3
-The 1 Component:
  scan component: 1
  dc table: 0
  ac table: 0
-The 2 Component:
  scan component: 2
  dc table: 1
  ac table: 1
-The 3 Component:
  scan component: 3
  dc table: 1
  ac table: 1
 start of spectral: 0
 end of spectral: 63
 approximation high: 0
 approximation low: 0

  基本上每個marker中所代表之意思已可從上述文件中取得,唯一需要注意的是在0xFFDA(Scan Header)結束後緊接著則是每個scan編碼後的data,該data長度並無標示,由於本次作業並無做到解碼部分,因此讀取時無法順利跳過該data直至0xFFD9
  另外值得注意的是,0xFFC4(Huffman Table)的marker會依據不同的處理軟體而有不一樣的個數,就如同老師上課所用之教學圖片(Rex.jpg),該圖便只有一個0xFFC4,然而這次作業的圖片(圖四)則有四個0xFFC4,針對每一張huffman table分別給一個marker,從上述文件中即可看出端倪
  接著說明撰寫程式時所需要注意的事項,在讀取檔案時,C++所使用的方式是以file stream讀取,但讀取方式是以getline()為主,而所謂getline(),說明了是只讀取檔案至字元'\n'為止稱為line,而其實字元'\n'並不會真的如期讀入陣列中,因此遇到字元'\n'時需自己補上0xA,否則會造成後續處理檔案之問題
  Jpeg的header中只要是存放length的兩個byte處理時同樣要注意,其存放方式是以big endian存放,而我們目前使用之pc皆以little endian,在此我以two-byte pointer(unsigned short*)指向該地址,讀入後再將little endian之數字改為big endian,如此便可正確讀取其length


沒有留言:

張貼留言