{"id":707,"date":"2013-09-05T17:18:17","date_gmt":"2013-09-05T09:18:17","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=707"},"modified":"2013-11-09T13:56:36","modified_gmt":"2013-11-09T05:56:36","slug":"memos-about-jpeg","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2013\/09\/memos-about-jpeg\/","title":{"rendered":"JPEG\u5b66\u4e60\u7b14\u8bb0"},"content":{"rendered":"<p>\u9605\u8bfb\u8d44\u6599:<br \/>\nJPEG File Interchange Format Version 1.02<br \/>\nJEITA CP-3451 Exif Version 2.2<br \/>\nDIGITAL COMPRESSION AND CODING OF CONTINUOUS-TONE STILL IMAGES \u2013 REQUIREMENTS AND GUIDELINES<br \/>\nThe JPEG Still Picture Compression Standard<br \/>\nJPEG \u7b80\u6613\u6587\u6863 V2.15 \u4e91\u98ce<br \/>\nlibjpeg 6b<br \/>\nJPEG \u539f\u7406\u8be6\u7ec6\u5b9e\u4f8b\u5206\u6790\u53ca\u5176\u5728\u5d4c\u5165\u5f0f Linux \u4e2d\u7684\u5e94\u7528 http:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-jpeg\/<br \/>\nJPEG\u6587\u4ef6\u7f16\/\u89e3\u7801\u8be6\u89e3 http:\/\/blog.csdn.net\/lpt19832003\/article\/details\/1713718<br \/>\nHuffman \u7f16\u7801\u538b\u7f29\u7b97\u6cd5 http:\/\/coolshell.cn\/articles\/7459.html<br \/>\nA SIMPLE EXAMPLE OF HUFFMAN CODING ON A STRING http:\/\/nerdaholyc.com\/a-simple-example-of-huffman-coding-on-a-string\/<\/p>\n<p><strong>\u8fd9\u662f\u4e00\u7bc7\u81ea\u5df1\u5b66\u4e60JPEG\u7684\u7b14\u8bb0\uff0c\u4f1a\u4e0d\u65ad\u5b8c\u5584\uff0c\u591a\u6570\u662f\u522b\u4eba\u7684\u5566\uff0c\u5c11\u8bb8\u81ea\u5df1\u7406\u89e3\uff0c\u5982\u6709\u7406\u89e3\u9519\u8bef\u8fd8\u8bf7\u6307\u51fa\uff01<\/strong><\/p>\n<p>1\u3001JPEG File\u683c\u5f0f\u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff1a\u6807\u8bb0\u7801\u548c\u538b\u7f29\u6570\u636e<br \/>\n\u6807\u8bb0\u7801\u75312\u4e2a\u5b57\u8282\u7ec4\u6210\uff0c\u4ee50xFF\u6253\u5934\uff0c\u540e\u9762\u7684\u4e00\u4e2a\u5b57\u8282\u6839\u636e\u542b\u4e49\u4e0d\u540c\u800c\u5b9a\u3002\u6bcf\u4e2a\u6807\u8bb0\u7801\u4e4b\u524d\u8fd8\u53ef\u4ee5\u52a0\u4efb\u610f\u4e2a0xFF\u6765\u586b\u5145\uff0c\u4ed6\u4eec\u6ca1\u6709\u4ec0\u4e48\u610f\u4e49\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fde\u7eed\u7684\u591a\u4e2a0xFF\u88ab\u89e3\u91ca\u6210\u4e00\u4e2a0xFF\u3002<\/p>\n<p>2\u3001<br \/>\n\u538b\u7f29\u7b97\u6cd5\u662fJPEG<br \/>\n\u8272\u5f69\u7a7a\u95f4\u662fYCbCr<br \/>\nAPP0\u6807\u8bb0\u7801\u662f\u5fc5\u987b\u7684<\/p>\n<p>\u5b57\u8282\u5e8f\u90fd\u662f\u5927\u7aef<\/p>\n<p>YCbCr\u7684Cb\u548cCr\u4e00\u822c\u90fd\u662f\u6709\u7b26\u53f7\u6570\uff0c\u4f46\u662f\u5728JPEG\u5f53\u4e2d\u90fd\u662f\u65e0\u7b26\u53f7\u6570\uff0c\u6240\u4ee5\u76ee\u524d\u5728JPEG\u5f53\u4e2d\u7684\u505a\u6cd5\u662fRGB\u5230YCbCr\u7684\u8f6c\u6362\u662f\u8ba1\u7b97\u597dCb\u548cCr\u4e4b\u540e\u5c06\u5176\u503c\u589e\u52a0128\uff0c\u518d\u505a\u540e\u7eed\u7684\u8fd0\u7b97\u3002<br \/>\nYCbCr\u5230RGB\u7684\u8ba1\u7b97\u662f\u5148\u5c06Cb\u548cCr\u7684\u503c\u51cf\u53bb128\u540e\u518d\u6765\u505a\u8f6c\u6362\u3002<\/p>\n<p>\u5047\u8bbe\u4e00\u4e2a\u6570\u636e\u5355\u5143\uff0c8 x 8\u7684\u539f\u59cb\u56fe\u50cf\u5982\u4e0b(\u8f6c\u5316\u4e3aYCbCr\u4e4b\u540e\u7684\u6570\u636e)\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n52   55   61   66   70   61   64   73\r\n\r\n63   59   55   90   109  85   69   72\r\n\r\n62   59   68   113  144  104  66   73\r\n\r\n63   58   71   122  154  106  70   69\r\n\r\n67   61   68   104  126  88   68   70\r\n\r\n79   65   60   70   77   68   58   75\r\n\r\n85   71   64   59   55   61   65   83\r\n\r\n87   79   69   68   65   76   78   94\r\n<\/pre>\n<p>3\u3001DCT(Discrete Cosine Transform)<br \/>\n\u5728\u505aFDCT(Forward DCT)\u53d8\u6362\u7684\u65f6\u5019\uff0cY\uff0cCb\u548cCr\u7684\u503c\u90fd\u8303\u56f4\u90fd\u662f-128 ~ 127\uff0c\u6240\u4ee5\u90fd\u8981\u88ab\u51cf\u53bb128\u3002<br \/>\n\u9002\u914d\u8303\u56f4\uff0c\u6bcf\u4e2a\u70b9\u90fd\u51cf\u53bb128\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n-76  -73  -67  -62  -58  -67  -64  -55\r\n\r\n-65  -69  -73  -38  -19  -43  -59  -56\r\n\r\n-66  -69  -60  -15  16   -24  -62  -55\r\n\r\n-65  -70  -57  -6   26   -22  -58  -59\r\n\r\n-61  -67  -60  -24  -2   -40  -60  -58\r\n\r\n-49  -63  -68  -58  -51  -60  -70  -53\r\n\r\n-43  -57  -64  -69  -73  -67  -63  -45\r\n\r\n-41  -49  -59  -60  -63  -52  -50  -34\r\n<\/pre>\n<p>\u4f7f\u7528FDCT\u5e76\u56db\u820d\u4e94\u5165\u53d6\u6700\u63a5\u8fd1\u7684\u6574\u6570\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n-415 -30  -61  27   56   -20  -2   0\r\n\r\n4    -22  -61  10   13   -7   -9   5\r\n\r\n-47  7    77   -25  -29  10   5    -6\r\n\r\n-49  12   34   -15  -10  6    2    2\r\n\r\n12   -7   -13  -4   -2   2    -3   3\r\n\r\n-8   3    2    -6   -2   1    4    2\r\n\r\n-1   0    0    -2   -1   -3   4    -1\r\n\r\n0    0    -1   -4   -1   0    1    2\r\n<\/pre>\n<p>DC(Direct Current)\/AC(Alternating Current)<br \/>\n\u4ec0\u4e48\u662fDC\uff1f\u4ec0\u4e48\u662fAC\uff1f<\/p>\n<p>4\u3001\u91cf\u5316\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n-26  -3   -6   2    2    -1   0    0\r\n\r\n0    -2   -4   1    1    0    0    0\r\n\r\n-3   1    5    -1   -1   0    0    0\r\n\r\n-4   1    2    -1   0    0    0    0\r\n\r\n1    0    0    0    0    0    0    0\r\n\r\n0    0    0    0    0    0    0    0\r\n\r\n0    0    0    0    0    0    0    0\r\n\r\n0    0    0    0    0    0    0    0\r\n\r\n0    0    0    0    0    0    0    0\r\n<\/pre>\n<p>5\u3001Zigzag<br \/>\nZigzag\u7684\u597d\u5904\uff0c\u5728\u5185\u5b58\u5f53\u4e2d\u8fde\u7eed\u7684\u70b9\u5728\u56fe\u7247\u4e0a\u4e5f\u662f\u76f8\u90bb\u7684\u4e86\uff0c\u800c\u4e14\u540e\u9762\u90fd\u662f\u8fde\u7eed\u76840\uff0c\u53ef\u4ee5\u7ee7\u7eed\u4f7f\u7528RLE\u538b\u7f29\u3002<br \/>\n\u4e8e\u662f\u5c31\u53d8\u6210\uff1a<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\u221226,\u22123,0,\u22123,\u22122,\u22126,2,\u22124,1,\u22124,1,1,5,1,2,\u22121,1,\u22121,2,0,0,0,0,0,\u22121,\u22121,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r\n<\/pre>\n<p>\u5b9e\u9645\u4e0a\u6211\u4eec\u7684DC\u7cfb\u6570\u5728\u7f16\u7801\u7684\u65f6\u5019\u4e0d\u4f1a\u7b97\u5230Zigzag\u91cc\u9762\uff0c\u56e0\u4e3aDC\u7cfb\u6570\u503c\u6bd4\u8f83\u5927\uff0c\u5e76\u4e14\u76f8\u90bb\u7684\u4e24\u4e2a\u6570\u636e\u5355\u5143\u7684DC\u5dee\u503c\u4e0d\u4f1a\u5f88\u5927\uff0c\u6240\u4ee5JPEG\u4f7f\u7528\u4e86\u5dee\u5206\u8109\u51b2\u8c03\u5236\u7f16\u7801(DPCM)\u5bf9\u76f8\u90bb\u4e24\u4e2a\u6570\u636e\u5355\u5143\u4e4b\u95f4\u7684DC\u7cfb\u6570\u8fdb\u884c\u5dee\u503c\u7f16\u7801\uff0c\u8fd9\u662f\u5229\u7528\u4e86\u4e24\u4e2a\u6570\u636e\u5355\u5143\u4e4b\u95f4\u7684\u76f8\u5173\u6027\u3002<br \/>\n\u5bf9\u5176\u4ed6\u768463\u4e2aAC\u7cfb\u6570\u4f1a\u91c7\u7528Zigzag\u7f16\u7801\u3002<\/p>\n<p>6\u3001RLE(Run Length Coding)<br \/>\n\u6211\u4eec\u6765\u7528\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u8be6\u7ec6\u8bf4\u660e\u4e00\u4e0b\uff0c\u5047\u8bbe\u4ee5\u4e0b\u662f\u4f7f\u7528Zigzag\u7f16\u7801\u8fc7\u768463\u4e2aAC\u7cfb\u6570\u6570\u636e\uff1a<br \/>\n<strong>57,45,0,0,0,0,23,0,-30,-16,0,0,1,0,0,0,0,0,0,0,..,0<\/strong><br \/>\n\u53ef\u4ee5\u8868\u793a\u4e3a<br \/>\n<strong>(0,57) ; (0,45) ; (4,23) ; (1,-30) ; (0,-16) ; (2\uff0c1) ; EOB<\/strong><br \/>\nEOB\u5b9e\u9645\u5c31\u662f\u7ed3\u675f\uff0c\u4e5f\u53ef\u4ee5\u7528(0,0)\u8868\u793a\uff0c\u5982\u679c\u6700\u540e\u9762\u4e0d\u662f\u4ee50\u7ed3\u675f\u7684\u5c31\u4e0d\u9700\u8981<br \/>\n\u89e3\u91ca\u4e0b\u8fd9\u4e2a\u542b\u4e49\uff0c\u7f16\u7801\u540e\u7684\u542b\u4e49\u5c31\u662f\u8bf4\u572857\u4e4b\u524d\u67090\u4e2a0\uff0c\u572845\u4e4b\u524d\u67090\u4e2a0\uff0c\u572823\u4e4b\u524d\u67094\u4e2a0\uff0c\u5728-30\u4e4b\u524d\u67091\u4e2a0\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002<br \/>\n\u9700\u8981\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u6211\u4eec\u540e\u9762\u8fd8\u4f1a\u5bf9\u8fd9\u6837\u7684\u6570\u636e\u4f7f\u7528Huffman\u538b\u7f29\uff0c\u4f46\u662f\u8be5\u7b97\u6cd5\u8981\u6c42\u8fd9\u4e2a\u8868\u793a0\u7684\u4e2a\u6570\u7684\u503c\u7684\u4f4d\u6570\u662f4bit\uff0c\u4e5f\u5c31\u662f\u8bf4\u80fd\u4fdd\u5b58\u7684\u503c\u7684\u8303\u56f4\u662f0 ~ 15\u3002<br \/>\n\u6240\u4ee5\u78b0\u5230\u8fde\u7eed\u5927\u4e8e15\u4e2a0\u7684\u60c5\u51b5\u7684\u65f6\u5019\uff0c\u6211\u4eec\u4f1a\u62c6\u5206(15,0) ; (3,2) ; &#8230; ; (15,0) ; (15,0) ; (1,4)\uff0c\u7528(15,0)\u8868\u793a\u8fde\u7eed\u768416\u4e2a0\uff0c\u4e5f\u5c31\u662f\u8868\u793a\uff1a<br \/>\n19\u4e2a0,2, &#8230; ,33\u4e2a0,4\u3002<\/p>\n<p>7\u3001Canonical Huffman Code<br \/>\n\u5728\u505a\u597d\u8fd9\u4e9b\u5de5\u4f5c\u4e4b\u540e\uff0cJPEG\u8fd8\u4f1a\u5bf9\u6570\u636e\u8fdb\u884c\u538b\u7f29\uff0c\u5229\u7528Canonical Huffman Code\u7f16\u7801\uff0c\u5bf9\u51fa\u73b0\u9891\u7387\u66f4\u9ad8\u7684\u6570\u636e\u91c7\u7528\u66f4\u77ed\u7684\u7801\u5b57\u6765\u7f16\u7801\u3002<br \/>\n\u8fd9\u91cc\u5c06\u6570\u503c\u6309\u7167\u4f4d\u6570\u5206\u4e3a\u4e8616\u7ec4\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n               \u6570\u503c                 \u7ec4              \u5b9e\u9645\u4fdd\u5b58\u503c\r\n                0                   0                   -\r\n              -1,1                  1                  0,1\r\n           -3,-2,2,3                2              00,01,10,11\r\n     -7,-6,-5,-4,4,5,6,7            3    000,001,010,011,100,101,110,111\r\n       -15,..,-8,8,..,15            4       0000,..,0111,1000,..,1111\r\n      -31,..,-16,16,..,31           5     00000,..,01111,10000,..,11111\r\n      -63,..,-32,32,..,63           6                   .\r\n     -127,..,-64,64,..,127          7                   .\r\n    -255,..,-128,128,..,255         8                   .\r\n    -511,..,-256,256,..,511         9                   .\r\n   -1023,..,-512,512,..,1023       10                   .\r\n  -2047,..,-1024,1024,..,2047      11                   .\r\n  -4095,..,-2048,2048,..,4095      12                   .\r\n  -8191,..,-4096,4096,..,8191      13                   .\r\n -16383,..,-8192,8192,..,16383     14                   .\r\n-32767,..,-16384,16384,..,32767    15                   .\r\n<\/pre>\n<p>\u4e4b\u524dRLE\u4e4b\u540e\u7684\u7ed3\u679c\uff1a<br \/>\n<strong>(0,57) ; (0,45) ; (4,23) ; (1,-30) ; (0,-16) ; (2\uff0c1) ; EOB<\/strong><br \/>\n\u73b0\u5728\u4ec5\u5bf9\u540e\u9762\u7684\u503c\u8fdb\u884c\u53d8\u6362\uff0c\u524d\u9762\u8868\u793a0\u7684\u4e2a\u6570\u7684\u503c\u4e0d\u52a8\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n    57\u662f\u7b2c6\u7ec4\u7684\uff0c\u5b9e\u9645\u4fdd\u5b58\u503c\u4e3a111001\uff0c\u6240\u4ee5\u88ab\u7f16\u7801\u4e3a(6,111001)\r\n    45\uff0c\u540c\u6837\u7684\u64cd\u4f5c\uff0c\u7f16\u7801\u4e3a (6,101101)\r\n    23  -&gt;  (5,10111)\r\n   -30  -&gt;  (5,00001)\r\n    -8  -&gt;  (4,0111)\r\n     1  -&gt;  (1,1)\r\n<\/pre>\n<p>\u524d\u9762\u7684\u90a3\u4e32\u6570\u5b57\u5c31\u53d8\u6210\u4e86:<br \/>\n<strong>(0,6), 111001 ; (0,6), 101101 ; (4,5), 10111; (1,5), 00001; (0,4) , 0111 ; (2,1), 1 ; (0,0)<\/strong><\/p>\n<p>\u62ec\u53f7\u91cc\u7684\u6570\u503c\u6b63\u597d\u5408\u6210\u4e00\u4e2a\u5b57\u8282\uff0c\u540e\u9762\u88ab\u7f16\u7801\u7684\u6570\u5b57\u8868\u793a\u8303\u56f4\u662f-32767 ~ 32767\u3002<br \/>\n\u5408\u6210\u7684\u5b57\u8282\u91cc\uff0c\u9ad84\u4f4d\u662f\u524d\u7eed0\u7684\u4e2a\u6570\uff0c\u4f4e4\u4f4d\u63cf\u8ff0\u4e86\u540e\u9762\u6570\u5b57\u7684\u4f4d\u6570\u3002<\/p>\n<p>\u63a5\u7740\u53d8\uff0c\u4e0b\u9762\u7684\u53d8\u5316\u5c31\u9700\u8981\u53bb\u67e5\u627eHuffman\u7f16\u7801\u8868\u4e86\uff0c\u8fd9\u4e2a\u662f\u5728\u538b\u7f29\u4e4b\u524d\u5c31\u5e94\u8be5\u6784\u5efa\u597d\u7684\uff0c\u8fd9\u4e2a\u8868\u662f\u5c060 ~ 255\u76848\u4f4d\u5b9a\u957f\u6570\u6839\u636e\u5176\u51fa\u73b0\u7684\u9891\u7387\u4e0d\u540c\u6620\u5c04\u6210\u4e3a1 ~ 16\u4f4d\u4e0d\u5b9a\u957f\u6570\uff0c\u9891\u7387\u5927\u7684\u5c0f\u4e8e8\u4f4d\uff0c\u9891\u7387\u5c0f\u7684\u9ad8\u4e8e8\u4f4d\u3002\u8fd9\u70b9\u5f88\u91cd\u8981\uff0c\u5f53\u7136\u8fd9\u4e2a\u8868\u662f\u5982\u4f55\u6784\u5efa\u51fa\u6765\u7684\u4e5f\u5f88\u91cd\u8981\u3002<br \/>\n\u73b0\u5728\u6211\u4eec\u5047\u8bbe\u67e5\u8868\u5f97\u77e5\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n 6 = (0,6)    ---  111000    (\u6ce8: 6 = 0 * 16 + 6 = 0x06)\r\n69 = (4,5)    ---  1111111110011001    (\u6ce8: 69 = 4 * 16 + 5 = 0x45)\r\n21 = (1,5)    ---  11111110110\r\n4  = (0,4)    ---  1011\r\n33 = (2,1)    ---  11011\r\n 0 = EOB = (0,0) ---  1010\r\n<\/pre>\n<p>\u90a3\u4e48\u6700\u7ec8\u6211\u4eec\u5f97\u5230\u7684AC\u7cfb\u6570\u6309\u4f4d\u6d41\u5c31\u5982\u4e0b\uff1a<br \/>\n<strong>111000 111001  111000 101101  1111111110011001 10111  11111110110 00001  1011 0111  11011 1  1010<\/strong><\/p>\n<p>\u597d\u5947\uff1a\u770b\u8d77\u6765\u524d\u9762\u62ec\u53f7\u91cc\u7528\u7684\u7f16\u7801(\u8303\u56f4\u4e3a0 ~ 255)\u548c\u540e\u9762\u7f16\u7801\u7684\u6570\u5b57\u8303\u56f4\u4e3a-32767 ~ 32767\u7684\u6765\u81ea\u4e0d\u540c\u7684\u7f16\u7801\u57fa\u7840\uff1f\u8fd9\u6837\u4e0d\u4f1a\u6df7\u6dc6\u4e48\uff1f<br \/>\n<strong>\u524d\u9762\u7684\u7f16\u7801\u6570\u636e(\u4e5f\u5c31\u662f\u8bf4\u4e4b\u524d\u7ec4\u5408\u8d77\u6765\u7684\u4e00\u5b57\u8282\u7684\u6570\u636e\uff0c\u9ad84\u4f4d0\u7684\u4e2a\u6570\uff0c\u4f4e4\u4f4d\u975e0\u6570\u636e\u7f16\u7801\u540e\u6240\u5360\u7684\u4f4d\u6570)\u53ef\u4ee5\u6839\u636eHuffman\u8868\u67e5\u8be2\u51fa\u6765\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5f97\u5230\u7d27\u8ddf\u7740\u7684\u6570\u636e\u7684\u4f4d\u6570\uff0c\u8bfb\u53d6\u76f8\u5e94\u7684\u6570\u636e\uff0c\u6240\u4ee5\u4e0d\u4f1a\u6df7\u6dc6\u3002<\/strong><\/p>\n<p>8\u3001DC\u7f16\u7801<br \/>\nDC\u5728\u6bcf\u4e2a\u6570\u636e\u5355\u5143\u4e4b\u4e2d\u53ea\u6709\u4e00\u4e2a\uff0c\u5e76\u4e14\u8fde\u7eed\u6570\u636e\u5355\u5143\u4e4b\u95f4\u7684DC\u6709\u7d27\u5bc6\u7684\u8054\u7cfb\uff0c\u6240\u4ee5JPEG\u5f53\u4e2d\u5c31\u91c7\u7528\u7684\u5dee\u5206\u8109\u51b2\u8c03\u5236\u7f16\u7801(DPCM)\u3002<br \/>\n\u76f8\u90bb\u5355\u5143\u4e4b\u95f4<br \/>\nDiff = DC(i) &#8211; DC(i-1)<br \/>\n\u6240\u4ee5<br \/>\nDC(i) = DC(i-1) + Diff<\/p>\n<p>\u6211\u4eec\u4fdd\u5b58\u7684DC\u90fd\u662f\u548c\u4e0a\u4e00\u4e2aDC\u7684\u5dee\u503c\uff0c\u6240\u4ee5DC(0)\u7b49\u4e8e\u591a\u5c11\uff1f\u4e91\u98ce\u8bf4\u662f0\uff0c\u6211\u89c9\u5f97\u4e0d\u5e94\u8be5\u554a\u3002<br \/>\n\u76ee\u524dDC\u76f8\u5173\u8fd9\u90e8\u5206\u9700\u8981\u8fdb\u4e00\u6b65\u8bc1\u5b9e\u3002<br \/>\n\u5047\u8bbeDiff\u4e3a-511<br \/>\n\u5c31\u4f1a\u88ab\u7f16\u7801\u6210(9, 000000000)<br \/>\n\u5047\u8bbe\u67e5\u8868(\u4e00\u822c\u5728JPEG\u6587\u4ef6\u5f53\u4e2dY\u548cC\u662f\u4e0d\u540c\u7684\u8868\uff0c\u53e6\u5916\u8fd8\u5206DC\u548cAC\uff0c\u6240\u4ee5\u901a\u5e38\u5c31\u67094\u4e2aHuffman\u8868)\u76849\u7684Huffman\u7f16\u7801\u4e3a1111110\uff0c\u90a3\u4e48\u6574\u4e2aDC\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5c31\u4e3a1111110 000000000\u3002<\/p>\n<p>\u5c06DC\u7684\u6570\u636e\u6d41\u653e\u5230AC\u4e4b\u524d\u5c31\u53ef\u4ee5\u7ec4\u6210\u5b8c\u6574\u7684\u7f16\u7801\u6570\u636e\u6d41\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n1111110 000000000  111000 111001  111000 101101  1111111110011001 10111  11111110110 00001  1011 0111  11011 1  1010\r\n<\/pre>\n<p>9\u3001\u7591\u95ee\uff1a<br \/>\nMCU\u548cDU\u4e4b\u95f4\u6709\u5173\u7cfb\u5417\uff1f\u770b\u8d77\u6765\u8fd9\u4e9b\u538b\u7f29\u90fd\u662f\u5728DU\u5f53\u4e2d\u8fdb\u884c\u7684\u3002<br \/>\n\u6bcf\u4e2aY\uff0cCb\uff0cCr\u5206\u91cf\u90fd\u8981\u6765\u8fd9\u6837\u538b\u7f29\u4e00\u6b21\u5417\uff1f\u8fd8\u662f3\u4e2a\u5206\u91cf\u4e00\u8d77\u538b\u7f29\uff1f\u6216\u8005\u8bf4\u662f\u53ef\u4ee5\u6839\u636e\u91c7\u6837\u7684\u4e0d\u540c\uff0c\u5c06\u90e8\u5206\u5206\u91cf\u653e\u5728\u4e00\u8d77\u538b\u7f29\uff0c\u6bd4\u5982Cb\u548cCr\u4e00\u8d77\u538b\u7f29\uff0cY\u5355\u72ec\u538b\u7f29\u3002<br \/>\n\u770b\u8d77\u6765Cb\u53ef\u4ee5\u548cCr\u653e\u5728\u4e00\u8d77\u538b\u7f29\u3002<br \/>\nUPDATE\uff1a<br \/>\nMCU\u53ef\u80fd\u6709\u4e00\u4e2a\u6216\u8005\u591a\u4e2aDU\u7ec4\u6210\uff0c\u538b\u7f29\u90fd\u662f\u6309DU\u6765\u7684\uff0c\u5206\u91cf\u90fd\u662f\u5206\u5f00\u538b\u7f29\u7684\uff0c\u4e00\u4e2aMCU\u5f53\u4e2d\u7684Y\uff0cCb\uff0cCr\u90fd\u662f\u5206\u522b\u538b\u7f29\u7684\uff0c\u7136\u540e\u6309MCU\u7ec4\u88c5\u6210\u5b57\u8282\u6d41\u3002<\/p>\n<p>10\u3001JFIF\u6587\u4ef6\u683c\u5f0f\u5206\u6790\u5b9e\u4f8b\uff1a<\/p>\n<p>SOI(Start of Image)<\/p>\n<p>APP0(JFIF application segment)<\/p>\n<p>APP1(application reserved)<br \/>\n&#8230;<br \/>\nAPP15<\/p>\n<p>DQT(Define Quantization Table)<\/p>\n<p>DHT(Difine Huffman Table)<\/p>\n<p>SOF(Start of Frame)<\/p>\n<p>SOS(Start of Scan)<\/p>\n<p>EOI(End of Image)<\/p>\n<p>IFD(Image File Directories)<\/p>\n<p>\u6807\u8bb0\u7684\u524d2\u4e2a\u5b57\u8282\u4e3a\u540d\u5b57\uff0c\u4e5f\u5c31\u662f\u524d\u9762\u6240\u8bf4\u7684\u6807\u8bb0\u7801\uff0c\u63a5\u7740\u76842\u4e2a\u5b57\u8282\u4e3a\u8be5\u6807\u8bb0\u7684\u6240\u5360\u7a7a\u95f4\u5927\u5c0f(\u4e0d\u5305\u542b\u6807\u8bb0\u540d\u5b57\u76842\u4e2a\u5b57\u8282\uff0c\u4f46\u5305\u542b\u81ea\u5df1\u5728\u5185)<br \/>\n\u6bd4\u5982\u8fd9\u4e00\u6bb5\u6570\u636e<br \/>\nFF E0 00 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00<br \/>\n\u5f53\u4e2d<br \/>\n0xFFE0\u4e3a\u6807\u8bb0\u7801\uff0c\u4e5f\u5c31\u662fAPP0<br \/>\n0x0010\u4e3a\u8be5\u6807\u8bb0\u6240\u5360\u5927\u5c0f\uff0c\u4e5f\u5c31\u662f16<br \/>\n\u540e\u9762\u8ddf\u768414\u4e2a\u5b57\u8282(&#8220;4A 46 49 46 00 01 01 00 00 01 00 01 00 00&#8221;)\u5c31\u662f\u6807\u8bb0\u5185\u5bb9<br \/>\n\u6839\u636eSPEC\u7684\u63cf\u8ff0\uff1a<br \/>\n5\u5b57\u8282\u4e3a\u6807\u8bc6\u7b26\uff0c\u8fd9\u91cc\u5c31\u662fJFIF0<br \/>\n2\u5b57\u8282\u4e3a\u7248\u672c\u53f7(\u4e3b\u7248\u672c\u548c\u6b21\u7248\u672c\u5404\u53601\u4e2a\u5b57\u8282)\uff0c\u8fd9\u91cc\u5c31\u662f1.01<br \/>\n1\u5b57\u8282\u4e3a\u5bc6\u5ea6\u5355\u4f4d\uff0c0\u8868\u793a\u6ca1\u6709\u5355\u4f4d\uff0c1\u8868\u793a\u6bcf\u82f1\u5bf8\u70b9\u6570\uff0c2\u8868\u793a\u6bcf\u5398\u7c73\u70b9\u6570<br \/>\n2\u5b57\u8282\u4e3a\u6c34\u5e73\u50cf\u7d20\u5bc6\u5ea6\uff0c\u8fd9\u91cc\u662f1<br \/>\n2\u5b57\u8282\u4e3a\u5782\u76f4\u50cf\u7d20\u5bc6\u5ea6\uff0c\u8fd9\u91cc\u662f1<br \/>\n1\u5b57\u8282\u4e3a\u7f29\u7565\u56fe\u6c34\u5e73\u50cf\u7d20\u603b\u6570\uff0c\u8fd9\u91cc\u662f0<br \/>\n1\u5b57\u8282\u4e3a\u7f29\u7565\u56fe\u5782\u76f4\u50cf\u7d20\u603b\u6570\uff0c\u8fd9\u91cc\u4e3a0<br \/>\n\u5982\u679c\u6ca1\u6709\u7f29\u7565\u56fe\uff0c\u8fd9\u4e24\u4e2a\u7f29\u7565\u56fe\u76f8\u5173\u7684\u5b57\u6bb5\u503c\u90fd\u5fc5\u987b\u8981\u4e3a0\uff0c\u5982\u679c\u4e0d\u4e3a0\u5c31\u8868\u793a\u540e\u9762\u8fd8\u6709\u7f29\u7565\u56fe\u7684RGB\u6570\u636e\uff0c\u5927\u5c0f\u662f3\u5b57\u8282\u7684\u500d\u6570\u3002<\/p>\n<p>\u5bf9\u4e8eDQT<\/p>\n<blockquote><p>\nFF DB 00 43 00 08 06 06 07 06 05 08 07 07 07 09 09 08 0A 0C 14 0D 0C 0B 0B 0C 19 12 13 0F 14 1D 1A 1F 1E 1D 1A 1C 1C 20 24 2E 27 20 22 2C 23 1C 1C 28 37 29 2C 30 31 34 34 34 1F 27 39 3D 38 32 3C 2E 33 34 32<br \/>\nFF DB 00 43 01 09 09 09 0C 0B 0C 18 0D 0D 18 32 21 1C 21 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32\n<\/p><\/blockquote>\n<p>0xFFDB\u4e3a\u6807\u8bb0\u7801<br \/>\n0x0043\u4e3a\u6240\u5360\u5927\u5c0f\uff0c\u4e5f\u5c31\u662f67(\u9664\u53bb\u672c\u8eab\u6240\u53602\u5b57\u8282\uff0c\u5927\u5c0f\u8ddf\u7cbe\u5ea6\u6709\u5173)<br \/>\n1\u4e2a\u5b57\u8282\u4e3aQT\u4fe1\u606f\uff0c\u9ad84\u4f4d\u4e3aQT\u7cbe\u5ea6\uff0c\u4f4e4\u4f4d\u4e3aQT\u53f7<br \/>\n\u8fd8\u539f\u6210\u77e9\u9635\u5f62\u5f0f(Zigzag)<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n8   6   5   8   12  20  26  31\r\n\r\n6   6   7   10  13  29  30  28\r\n\r\n7   7   8   12  20  29  35  28\r\n\r\n7   9   11  15  26  44  40  31\r\n\r\n9   11  19  28  34  55  52  39\r\n\r\n12  18  28  32  41  52  57  46 \r\n\r\n25  32  39  44  52  61  60  51\r\n\r\n36  46  48  49  56  50  52  50\r\n<\/pre>\n<p>\u5c31\u662f\u8fd9\u6837(JPEG \u539f\u7406\u8be6\u7ec6\u5b9e\u4f8b\u5206\u6790\u53ca\u5176\u5728\u5d4c\u5165\u5f0f Linux \u4e2d\u7684\u5e94\u7528\u8fd9\u7bc7\u6587\u7ae0\u4e2d\u5e94\u8be5\u753b\u9519\u4e86)<br \/>\n\u53e6\u5916\u4e00\u4e2aQT\u4e5f\u662f\u540c\u6837\u7684\u65b9\u6cd5\u53ef\u4ee5\u8fd8\u539f\u3002<\/p>\n<p>\u5bf9\u4e8eSOF0\u8fd9\u6bb5\u6570\u636e<br \/>\nFF C0 00 11 08 00 95 00 E3 03 01 22 00 02 11 01 03 11 01<br \/>\n\u5f53\u4e2d<br \/>\n0xFFC0\u8868\u793aSOF0<br \/>\n2\u4e2a\u5b57\u8282\u4e3a\u957f\u5ea6\uff0c0x0011\uff0c\u537317<br \/>\n1\u4e2a\u5b57\u8282\u4e3a\u6570\u636e\u6837\u672c\u7684\u7cbe\u5ea6\uff0c\u8fd9\u91cc\u662f8\u4f4d<br \/>\n2\u4e2a\u5b57\u8282\u8868\u793a\u56fe\u50cf\u7684\u9ad8\u5ea6\uff0c\u8fd9\u91cc\u662f149<br \/>\n2\u4e2a\u5b57\u8282\u8868\u793a\u56fe\u50cf\u7684\u5bbd\u5ea6\uff0c\u8fd9\u91cc\u662f227<br \/>\n1\u4e2a\u5b57\u8282\u8868\u793a\u989c\u8272\u5206\u91cf\u6570\uff0cJPEG\u90fd\u662fYCrCb\uff0c\u53733<br \/>\n9\u4e2a\u5b57\u8282\u8868\u793a\u989c\u8272\u5206\u91cf\u4fe1\u606f\uff0c\u8fd9\u91cc\u5b57\u8282\u6570\u662f\u989c\u8272\u5206\u91cf\u6570 multiply 3<br \/>\n\u56e0\u4e3a\u5206\u91cf\u4fe1\u606f\u4e2d\u989c\u8272\u5206\u91cfID\u5360\u75281\u4e2a\u5b57\u8282\uff0c\u6c34\u5e73\/\u5782\u76f4\u56e0\u5b50\u5360\u75281\u4e2a\u5b57\u8282(\u9ad84\u4f4d\u6c34\u5e73\uff0c\u4f4e4\u4f4d\u5782\u76f4)\uff0c\u91cf\u5316\u8868\u5360\u75281\u4e2a\u5b57\u8282<br \/>\nH 2:1:1<br \/>\nV 2:1:1<br \/>\n\u6240\u4ee5\u603b\u4f53\u91c7\u6837\u56e0\u5b50\u5c31\u662f(2 * 2):(1 * 1):(1 * 1)\uff0c\u53734:1:1<\/p>\n<p>MCU\u5bbd\u662f\u6c34\u5e73\u91c7\u6837\u56e0\u5b50\u6700\u5927\u503c multiply 8(\u8bb0\u8be5\u6700\u5927\u503c\u4e3aHmax)<br \/>\nMCU\u9ad8\u662f\u5782\u76f4\u91c7\u6837\u56e0\u5b50\u6700\u5927\u503c multiply 8(\u8bb0\u8be5\u6700\u5927\u503c\u4e3aVmax)<br \/>\n\u56e0\u6b64\u8fd9\u91cc\u5c31\u662f(Hmax * 8):(Vmax * 8) = 16:16<\/p>\n<p>\u5982\u679c\u6574\u5e45\u56fe\u7247\u7684\u9ad8\u5ea6\u6216\u8005\u5bbd\u5ea6\u4e0d\u662fMCU\u7684\u6574\u6570\u500d\uff0c\u5c31\u9700\u8981padding\uff0c\u89e3\u7801\u4e4b\u540e\u4e22\u5f03\u5927\u4e8e\u5bbd\u5ea6\u6216\u8005\u9ad8\u5ea6\u90e8\u5206\u7684\u6570\u636e<\/p>\n<p>\u5728\u6570\u636e\u6d41\u5f53\u4e2d\uff0cMCU\u662f\u6309\u4ece\u5de6\u5230\u53f3\uff0c\u4ece\u4e0a\u5230\u4e0b\u6765\u6392\u5217\u7684\u3002<\/p>\n<p>\u56e0\u4e3a\u6bcf\u4e2aMCU\u7531\u82e5\u5e72\u6570\u636e\u5355\u5143\u7ec4\u6210\uff0c\u800c\u6570\u636e\u5355\u5143\u53c8\u5fc5\u987b\u662f8:8\u7684\uff0c\u6240\u4ee5MCU\u5f53\u4e2d\u6570\u636e\u5355\u5143\u7684\u4e2a\u6570\u5c31\u662f4(Hmax * Vmax)<\/p>\n<p>\u5bf9\u4e8eDHT\uff0c\u5982\u4e0b\u5c31\u67094\u4e2aHuffman\u8868<\/p>\n<blockquote><p>\nFF C4 00 1F 00 00 01 05 01 01 01 01 01 01 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0A 0B<br \/>\nFF C4 00 B5 10 00 02 01 03 03 02 04 03 05 05 04 04 00 00 01 7D 01 02 03 00 04 11 05 12 21 31 41 06 13 51 61 07 22 71 14 32 81 91 A1 08 23 42 B1 C1 15 52 D1 F0 24 33 62 72 82 09 0A 16 17 18 19 1A 25 26 27 28 29 2A 34 35 36 37 38 39 3A 43 44 45 46 47 48 49 4A 53 54 55 56 57 58 59 5A 63 64 65 66 67 68 69 6A 73 74 75 76 77 78 79 7A 83 84 85 86 87 88 89 8A 92 93 94 95 96 97 98 99 9A A2 A3 A4 A5 A6 A7 A8 A9 AA B2 B3 B4 B5 B6 B7 B8 B9 BA C2 C3 C4 C5 C6 C7 C8 C9 CA D2 D3 D4 D5 D6 D7 D8 D9 DA E1 E2 E3 E4 E5 E6 E7 E8 E9 EA F1 F2 F3 F4 F5 F6 F7 F8 F9 FA<br \/>\nFF C4 00 1F 01 00 03 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0A 0B<br \/>\nFF C4 00 B5 11 00 02 01 02 04 04 03 04 07 05 04 04 00 01 02 77 00 01 02 03 11 04 05 21 31 06 12 41 51 07 61 71 13 22 32 81 08 14 42 91 A1 B1 C1 09 23 33 52 F0 15 62 72 D1 0A 16 24 34 E1 25 F1 17 18 19 1A 26 27 28 29 2A 35 36 37 38 39 3A 43 44 45 46 47 48 49 4A 53 54 55 56 57 58 59 5A 63 64 65 66 67 68 69 6A 73 74 75 76 77 78 79 7A 82 83 84 85 86 87 88 89 8A 92 93 94 95 96 97 98 99 9A A2 A3 A4 A5 A6 A7 A8 A9 AA B2 B3 B4 B5 B6 B7 B8 B9 BA C2 C3 C4 C5 C6 C7 C8 C9 CA D2 D3 D4 D5 D6 D7 D8 D9 DA E2 E3 E4 E5 E6 E7 E8 E9 EA F2 F3 F4 F5 F6 F7 F8 F9 FA\n<\/p><\/blockquote>\n<p>2\u4e2a\u5b57\u8282\u4e3a\u6807\u8bb0\u7801<br \/>\n2\u4e2a\u5b57\u8282\u4e3a\u957f\u5ea6<br \/>\n1\u4e2a\u5b57\u8282\u4e3a\u7c7b\u578b\u548cID\uff0c\u9ad84\u4f4d\u4e3a\u7c7b\u578b\uff0c0\u4e3aDC\u76f4\u6d41\uff0c1\u4e3aAC\u4ea4\u6d41\uff1b\u4f4e4\u4f4d\u4e3aID<br \/>\n\u4e5f\u5c31\u662f\u8bf4\u8fd9\u91cc\u67094\u4e2aHuffman\u7f16\u7801\u8868\uff0c\u76f4\u6d410\uff0c\u4ea4\u6d410\uff0c\u76f4\u6d411\uff0c\u4ea4\u6d411<br \/>\n16\u4e2a\u5b57\u8282\u4e3a\u7801\u5b57\u7684\u6570\u91cf\uff0c\u4ee5\u7b2c\u4e00\u5f20\u8868\u4e3a\u4f8b\u5b50\uff0c\u6ca1\u67091\u4f4d\u7684\u7801\u5b57\uff0c2\u4f4d\u7684\u7801\u5b571\u4e2a\uff0c3\u4f4d\u7684\u7801\u5b575\u4e2a\uff0c4\u52309\u4f4d\u7684\u7801\u5b57\u54041\u4e2a\uff0c\u6ca1\u67099\u4f4d\u4ee5\u4e0a\u7684\u7801\u5b57\uff0c\u6240\u4ee5\u4e00\u5171\u662f12\u4e2a\u7801\u5b57<br \/>\n\u5269\u4e0b\u768412\u5b57\u8282\u4e3a\u7f16\u7801\u5185\u5bb9(\u8fd912\u662f\u6839\u636e\u7801\u5b57\u6570\u91cf\u5f97\u51fa\u7684\uff0c1 + 5 + 1 + 1 + 1 + 1 + 1 + 1)\uff0c<br \/>\n00 01 02 03 04 05 06 07 08 09 0A 0B<br \/>\n\u6240\u4ee5\u8f6c\u6362\u6210\u4e8c\u8fdb\u5236\u7684\u8bdd\u5c31\u5e94\u5f53\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\u4f4d\u6570      \u4ee3\u7801                 \u7801\u5b57\r\n2         00                  00\r\n3         01\/02\/03\/04\/05      001\/010\/011\/100\/101\r\n4         06                  0110\r\n5         07                  00111\r\n6         08                  001000\r\n7         09                  0001001\r\n8         0A                  00001010\r\n9         0B                  000001011\r\n<\/pre>\n<p>UPDATE: \u8fd9\u4e0a\u9762\u7684\u7f16\u7801\u5185\u5bb9\u7684\u7406\u89e3\u5e94\u8be5\u662f\u9519\u8bef\u7684\uff0c\u8fd9\u662f\u53c2\u7167http:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-jpeg\/\u6765\u7684\u3002<br \/>\n\u5b9e\u9645\u5e94\u8be5\u662f\uff1a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nLength    Code                Codeword    \r\n2         00                  00\r\n3         01                  010\r\n3         02                  011\r\n3         03                  100\r\n3         04                  101\r\n3         05                  110\r\n4         06                  1110\r\n5         07                  11110\r\n6         08                  111110\r\n7         09                  1111110\r\n8         0A                  11111110\r\n9         0B                  111111110\r\n<\/pre>\n<p>\u8fd9\u4e2aHuffman\u8868\u662f\u5982\u4f55\u6784\u5efa\u7684\uff0c\u5f97\u597d\u597d\u7814\u7a76\uff0c\u53e6\u5916\u540e\u9762\u7684\u538b\u7f29\u90fd\u4f1a\u7528\u5230\u8fd9\u4e2a\u8868\u7684\u5185\u5bb9\u3002<br \/>\n<strong>Huffman\u7f16\u7801\u8868\u7684\u6784\u5efa\u539f\u7406<\/strong><br \/>\n\u7b2c1\u4e2a\u7801\u5b57\u5fc5\u987b\u662f0(\u6839\u636e\u5176\u4f4d\u6570\u5177\u4f53\u8868\u73b0\u4e3a0\u621600\u6216000\u7b49\u7b49\uff0c\u4ee5\u6b64\u7c7b\u63a8)<br \/>\n\u4e0b\u4e00\u4e2a\u7801\u5b57\u5728\u524d\u9762\u4e00\u4e2a\u7684\u57fa\u7840\u4e0a\u52a01\uff0c\u5982\u679c\u4f4d\u6570\u6709\u589e\u52a0\uff0c\u5219\u52a01\u4e4b\u540e\u8865\u96f6\u5230\u76f8\u5e94\u4f4d\u6570<br \/>\n\u503c\u4e3a00\u7684\u4e3a\u7ed3\u675f\u6807\u5fd7(EOB)\uff0c\u7f16\u7801\u6216\u8005\u89e3\u7801\u65f6\u5019\u6ce8\u610f\u5176\u7801\u5b57<\/p>\n<p>EXIF\u901a\u5e38\u662f\u653e\u5728APP1\u5f53\u4e2d<br \/>\nFF E1 66 59 &#8230;&#8230; FF D9<br \/>\n0xFFE1(2\u5b57\u8282)\u5c31\u662fAPP1\u7684Marker\u540d\u5b57\uff0c0x6559(2\u5b57\u8282)\u662f\u8be5\u5b57\u6bb5\u7684\u957f\u5ea6\uff0c\u4e3a26201\uff0c\u4f46\u662f\u4e0d\u5305\u542bTAG\u540d\u5b57\u6240\u5360\u7528\u76842\u4e2a\u5b57\u8282\u3002\u4e5f\u5c31\u662f\u8bf4\u540e\u9762\u7684\u5b9e\u9645\u5185\u5bb9\u5360\u7528\u4e8626199\u4e2a\u5b57\u8282\uff0c\u76f4\u52300xFFD9\uff0c\u8fd9\u5c31\u662fEXIF\u7684\u5185\u5bb9\u3002\u4e3a\u4ec0\u4e48\u4f1a\u6709\u4e2a0xFFD9\u5462\uff1f\u6211\u4eec\u90fd\u77e5\u90530xFFD9\u662fEOI\uff0c\u56e0\u4e3aEXIF\u91cc\u9762\u7684\u7f29\u7565\u56fe\u5b9e\u9645\u4e0a\u4e5f\u662f\u4e00\u4e2a\u5b8c\u6574\u7684JPEG\u56fe\u7247\uff0c\u5b83\u4e5f\u6709SOI\u7b49\u7b49\u8fd9\u4e00\u4e9bMarker\u3002<br \/>\n\u53c2\u89c1JEITA CP-3451 Exif Version 2.2\u7684Figure 7 Structure of Exif file with compressed thumbnail<br \/>\n\u56e0\u4e3aEXIF\u5e76\u4e0d\u662fJPEG\u5fc5\u987b\u7684\uff0c\u6240\u4ee5\u4f60\u628a\u8fd9\u4e4b\u95f4\u7684\u5185\u5bb9\u6574\u4e2a\u90fd\u62ff\u6389(\u752816\u8fdb\u5236\u7f16\u8f91\u5668\u5f88\u597d\u505a\u5230\uff0c\u6709\u5174\u8da3\u7684\u53ef\u4ee5\u8bd5\u8bd5\u770b)\uff0c\u5bf9\u56fe\u7247\u4e5f\u6ca1\u6709\u4ec0\u4e48\u5f71\u54cd\uff0c\u53ea\u662f\u5c11\u4e86\u6240\u6709EXIF\u7684\u4fe1\u606f\u3002<\/p>\n<p>11\u3001Linux\u4e0b\u7f16\u8bd1libjpeg<br \/>\ndownload source tree<br \/>\nuncompress it<br \/>\ncd to source tree folder<br \/>\nclean the source tree<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ .\/configure --enable-shared --enable-static<\/pre>\n<p>Maybe it will complain this message<br \/>\n.\/configure: 1562: .\/ltconfig: not found \/\/ Here<br \/>\nbut it does not matter, so we do not care it.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ make<\/pre>\n<p>if it complains &#8216;make: .\/libtool: Command not found&#8217;<br \/>\nthen fix your configure file from<br \/>\nLIBTOOL=&#8221;.\/libtool&#8221;<br \/>\nto<br \/>\nLIBTOOL=&#8221;libtool&#8221;<br \/>\n&#8216;Cause under your current source tree, there is of course no file named libtool, so it can not exec that command, so replace it with the system-wide libtool. BUT the prerequisite thing is that you have installed libtool on your host machine.<\/p>\n<p>Then compile it again, everything should be okay.<\/p>\n<p>After completed, remember there will be a folder name &#8216;.libs&#8217; generated under your source tree folder, this is a HIDDEN folder, everything you need just under it.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ .\/cjpeg testimg.bmp &gt; hello.jpeg<\/pre>\n<p>a new compressed jpeg file is generated<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ .\/djpeg -bmp testimg.jpg &gt; hello.bmp<\/pre>\n<p>a new bmp file is generated<\/p>\n<p>use your imagination to do anything.<\/p>\n<p>Good luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9605\u8bfb\u8d44\u6599: JPEG File Interchange Format Version 1.02 JEITA CP-3451 Exif Version 2.2 DIGITAL COMPRESSION AND CODING OF CONTINUOUS-TONE STILL IMAGES \u2013 REQUIREMENTS AND GUIDELINES The JPEG Still Picture Compression Standard JPEG \u7b80\u6613\u6587\u6863 V2.15 \u4e91\u98ce libjpeg 6b JPEG \u539f\u7406\u8be6\u7ec6\u5b9e\u4f8b\u5206\u6790\u53ca\u5176\u5728\u5d4c\u5165\u5f0f Linux \u4e2d\u7684\u5e94\u7528 http:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-jpeg\/ JPEG\u6587\u4ef6\u7f16\/\u89e3\u7801\u8be6\u89e3 http:\/\/blog.csdn.net\/lpt19832003\/article\/details\/1713718 Huffman \u7f16\u7801\u538b\u7f29\u7b97\u6cd5 http:\/\/coolshell.cn\/articles\/7459.html A SIMPLE EXAMPLE OF HUFFMAN CODING ON A STRING &hellip; <a href=\"https:\/\/guoh.ai\/lifelog\/2013\/09\/memos-about-jpeg\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">JPEG\u5b66\u4e60\u7b14\u8bb0<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[34,8],"tags":[],"class_list":["post-707","post","type-post","status-publish","format-standard","hentry","category-multimedia","category-paste"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=707"}],"version-history":[{"count":10,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/707\/revisions"}],"predecessor-version":[{"id":709,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/707\/revisions\/709"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}