1. yuv420p 16×16 像素点 384字节全部数据
把上面的384个char从左到右,从上到下的顺序输入文件,就能显示红绿蓝白4个水平条
2. 256字节的亮度分量
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,
40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,
40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,
40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,40 ,
235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,
235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,
235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,
235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,235 ,
Y 分量要8×8 分割,UV 刚好64字节不用分割
3 . 64字节的U分量
90 ,90 ,90 ,90 ,90 ,90 ,90 ,90 ,
90 ,90 ,90 ,90 ,90 ,90 ,90 ,90 ,
53 ,53 ,53 ,53 ,53 ,53 ,53 ,53 ,
53 ,53 ,53 ,53 ,53 ,53 ,53 ,53 ,
239 ,239 ,239 ,239 ,239 ,239 ,239 ,239 ,
239 ,239 ,239 ,239 ,239 ,239 ,239 ,239 ,
128 ,128 ,128 ,128 ,128 ,128 ,128 ,128 ,
128 ,128 ,128 ,128 ,128 ,128 ,128 ,128 ,
4. 64字节的V 分量
239 ,239 ,239 ,239 ,239 ,239 ,239 ,239 ,
239 ,239 ,239 ,239 ,239 ,239 ,239 ,239 ,
34 ,34 ,34 ,34 ,34 ,34 ,34 ,34 ,
34 ,34 ,34 ,34 ,34 ,34 ,34 ,34 ,
109 ,109 ,109 ,109 ,109 ,109 ,109 ,109 ,
109 ,109 ,109 ,109 ,109 ,109 ,109 ,109 ,
128 ,128 ,128 ,128 ,128 ,128 ,128 ,128 ,
128 ,128 ,128 ,128 ,128 ,128 ,128 ,128 ,
5. Y分割为4个8×8块
y0:
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
144 ,144 ,144 ,144 ,144 ,144 ,144 ,144 ,
y1:
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 ,
81 ,81 ,81 ,81 ,81 ,81 ,81 ,81 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,0 ,0 ,0 ,0 ,
56 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
58 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
++++++++
V: 余弦变换
-4 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
204 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
413 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
262 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
-175 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
-171 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
-40 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
++++++++
==============================================================
JPEG 官方通用量化表
unsigned char lhb0[0x45]={0xff ,0xdb ,0 ,0x43 ,0 ,
16,11,10,16,24,40,51,61,
12,12,14,19,26,58,60,55,
14,13,16,24,40,57,69,56,
14,17,22,29,51,87,80,62,
18,22,37,56,68,109,103,77,
24,35,55,64,81,104,113,92,
49,64,78,87,103,121,120,101,
72,92,95,98,112,100,103,99};
unsigned char lhb1[0x45]={0xff,0xdb ,0 ,0x43 ,1 ,
17,18,24,47,99,99,99,99,
18,21,26,66,99,99,99,99,
24,26,56,99,99,99,99,99,
47,66,99,99,99,99,99,99,
99,99,99,99,99,99,99,99,
99,99,99,99,99,99,99,99,
99,99,99,99,99,99,99,99,
99,99,99,99,99,99,99,99
};
=========================================================
JPEG 官方通用霍夫曼表
unsigned char hfm0[] = {0xff, 0xc4, 0, 0x1f, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb
};
unsigned char hfm1[] = { 255, 196, 0, 181, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 1, 2, 3, 0, 4, 17,
5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240,
36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69,
70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118,
119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162,
163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198,
199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233,
234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250
};
unsigned char hfm2[] = { 255, 196, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
unsigned char hfm3[] = {255, 196, 0, 181, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2,
119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177,
193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41,
42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101,
102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137,
138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179,
180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214,
215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249,
250
};
========================================================================= 4个Y Z排序:第一个是DC,后面是AC
(0,-7), (1,-19), (6,5), (10,-2), (0,0),
(0,-7), (1,-19), (6,5), (10,-2), (0,0),
(0,4), (1,-58), (6,17), (10,-6), (14,1), (0,0),
(0,4), (1,-58), (6,17), (10,-6), (14,1), (0,0),
U:
(0,0), (1,-16), (0,-5), (5,7), (10,-2), (0,0),
V:
(0,0), (1,11), (0,17), (5,5), (10,-1), (0,-1), (0,0),
==================================================================
unsigned char zhen[] = {255, 192, 0, 17, 8, 0, 16, 0, 16, 3, 1, 0x22, 0, 2, 0x11, 1, 3, 0x11, 1 }; //帧头
unsigned char sos[] = {255, 218, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0 }; //比特流开始
=====================================================================
Y,U,V比特流:
131 ,251 ,51 ,254 ,154 ,255 ,0 ,227 ,180 ,127 ,102 ,127 ,211 ,95 ,252 ,118 ,173 ,255 ,0 ,194 ,11 ,255 ,0 ,81 ,31 ,252 ,131 ,255 ,0 ,215 ,163 ,254 ,16 ,95 ,250 ,136 ,255 ,0 ,228 ,31 ,254 ,189 ,31 ,217 ,244 ,191 ,231 ,255 ,0 ,254 ,74 ,31 ,91 ,204 ,127 ,231 ,239 ,224 ,143
--------------------------------
比特流的存储顺序:先是4个Y,再是U,最后是V。
YUV420P 三分量存储顺序是:首先存全部图片的Y分量,再存全部∪分量,最后存V分量。Y分量数等于图片像数,也就是图片的长X宽。U和V的数量相同,都等于1/4 长X宽。
————————————————
版权声明:本文为CSDN博主「乐山劲松」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_59802969/article/details/135395665
|