Arithmetic CodingAdditional Material Spring 2015.ppt
《Arithmetic CodingAdditional Material Spring 2015.ppt》由会员分享,可在线阅读,更多相关《Arithmetic CodingAdditional Material Spring 2015.ppt(71页珍藏版)》请在麦多课文档分享上搜索。
1、Arithmetic Coding Additional Material Spring 2015,CMPT 365 Multimedia Systems,Outline Part I,Introduction Basic Encoding and Decoding Scaling and Incremental Coding Integer Implementation Adaptive Arithmetic Coding Binary Arithmetic Coding Applications JBIG, H.264, JPEG 2000,Limitations of Huffman C
2、ode,Need a probability distribution,Hard to adapt to changing statistics,Minimum codeword length is 1 bit Serious penalty for high-probability symbols,Example: Binary source, P(0)=0.9 Entropy: -0.9*log2(0.9)-0.1*log2(0.1) = 0.469 bit Huffman code: 0, 1 Avg. code length: 1 bit Joint coding is not pra
3、ctical for large alphabet.,Arithmetic coding: Can resolve all of these problems. Code a sequence of symbols without having to generate codes for all sequences of that length.,Introduction,1,00,010 011,Recall table look-up decoding of Huffman code N: alphabet size L: Max codeword length Divide 0, 2L
4、into N intervals One interval for one symbol Interval size is roughly proportional to symbol prob.,dcba,Arithmetic Coding,Disjoint and complete partition of the range 0, 1) 0, 0.8), 0.8, 0.82), 0.82, 1) Each interval corresponds to one symbol Interval size is proportional to symbol probability,Obser
5、vation: once the tag falls into an interval, it never gets out of it,0,1,a b c,Some Questions to think about:,Why compression is achieved this way? How to implement it efficiently? How to decode the sequence? Why is it better than Huffman code?,Example:,Map to real line range 0, 1) Order does not ma
6、tter Decoder need to use the same order,Disjoint but complete partition: 1: 0, 0.8): 0, 0.7999999 2: 0.8, 0.82): 0.8, 0.8199999 3: 0.82, 1): 0.82, 0.9999999 (Think about the impact to integer implementation),Encoding,Input sequence: “1321”,Range 1,Final range: 0.7712, 0.773504): Encode 0.7712,Diffic
7、ulties: 1. Shrinking of interval requires high precision for long sequence.2. No output is generated until the entire sequence has been processed.,Cumulative Density Function (CDF),For continuous distribution:,For discrete distribution:,Properties: Non-decreasing Piece-wise constant Each segment is
8、closed at the lower end.,Encoder Pseudo Code,low=0.0, high=1.0; while (not EOF) n = ReadSymbol(); RANGE = HIGH - LOW; HIGH = LOW + RANGE * CDF(n); LOW = LOW + RANGE * CDF(n-1); output LOW;,Keep track of LOW, HIGH, RANGE Any two are sufficient, e.g., LOW and RANGE.,Decoding,Decode 1,Drawback: need to
9、 recalculate all thresholds each time.,Simplified Decoding,Normalize RANGE to 0, 1) each time No need to recalculate the thresholds.,Decoder Pseudo Code,Low = 0; high = 1; x = Encoded_number While (x low) n = DecodeOneSymbol(x); output symbol n; x = (x - CDF(n-1) / (CDF(n) - CDF(n-1); ;,Outline,Intr
10、oduction Basic Encoding and Decoding Scaling and Incremental Coding Integer Implementation Adaptive Arithmetic Coding Binary Arithmetic Coding Applications JBIG, H.264, JPEG 2000,Scaling and Incremental Coding,Problems of Previous examples: Need high precision No output is generated until the entire
11、 sequence is encoded,Key Observation: As the RANGE reduces, many MSBs of LOW and HIGH become identical: Example: Binary form of 0.7712 and 0.773504:0.1100010, 0.1100011, We can output identical MSBs and re-scale the rest: Incremental encoding This also allows us to achieve infinite precision with fi
12、nite-precision integers.,E1 and E2 Scaling,E1: LOW HIGH) in 0, 0.5) LOW: 0.0xxxxxxx (binary), HIGH: 0.0xxxxxxx.,0 0.5 1.0,Encoding with E1 and E2,0 0.8 1.0,Input 1,Encode any value in the tag, e.g., 0.5Output 1 All outputs: 1100011,To verify,LOW = 0.5424 (0.10001010. in binary), HIGH = 0.54816 (0.10
13、001100. in binary). So we can send out 10001 (0.53125) Equivalent to E2E1E1E1E2 After left shift by 5 bits: LOW = (0.5424 0.53125) x 32 = 0.3568 HIGH = (0.54816 0.53125) x 32 = 0.54112 Same as the result in the last page.,Comparison with Huffman,Input Symbol 1 does not cause any output Input Symbol
14、3 generates 1 bit Input Symbol 2 generates 5 bits,Symbols with larger probabilities generates less number of bits. Sometimes no bit is generated at all Advantage over Huffman coding Large probabilities are desired in arithmetic coding Can use context-adaptive method to create larger probabilityand t
15、o improve compression ratio.,Note: Complete all possible scaling beforeencoding the next symbol,Incremental Decoding,0 0.8 1.0,Decode 1: Need 5 bits (verify) Read 6 bits: Tag: 110001, 0.765625,Input 1100011,Summary: Complete all possible scaling before further decodingAdjust LOW, HIGH and Tag togeth
16、er.,Summary Part I,Introduction Encoding and Decoding Scaling and Incremental Coding E1, E2 Next: Integer Implementation E3 scaling Adaptive Arithmetic Coding Binary Arithmetic Coding Applications JBIG, H.264, JPEG 2000,Outline Part II,Review Integer Implementation Integer representation E3 Scaling
17、Minimum word length Binary Arithmetic Coding Adaptive Arithmetic Coding,Encoding Without Scaling,Input sequence: “1321”,Range 1,Final range: 0.7712, 0.773504): Encode 0.7712,E1 and E2 Scaling,E1: LOW HIGH) in 0, 0.5) LOW: 0.0xxxxxxx (binary), HIGH: 0.0xxxxxxx.,0 0.5 1.0,Encoding with E1 and E2,0 0.8
18、 1.0,Input 1,Encode any value in the tag, e.g., 0.5Output 1 All outputs: 1100011,To verify,LOW = 0.5424 (0.10001010. in binary), HIGH = 0.54816 (0.10001100. in binary). So we can send out 10001 (0.53125) Equivalent to E2E1E1E1E2 After left shift by 5 bits: LOW = (0.5424 0.53125) x 32 = 0.3568 HIGH =
19、 (0.54816 0.53125) x 32 = 0.54112 Same as the result in the last page.,Encoding Pseudo Code with E1, E2,EncodeSymbol(n) /Update variablesRANGE = HIGH - LOW;HIGH = LOW + RANGE * CDF(n);LOW = LOW + RANGE * CDF(n-1);/keep scaling before encoding next symbolwhile LOW, HIGH in 0, 0.5) or 0.5, 1) send 0 f
20、or E1 and 1 for E2scale LOW, HIGH ,(For floating-point implementation),Incremental Decoding,0 0.8 1.0,Decode 1: Need 5 bits (verify) Read 6 bits: Tag: 110001, 0.765625,Input 1100011,Summary: Complete all possible scaling before further decodingAdjust LOW, HIGH and Tag together.,Decoding Pseudo Code
21、with E1, E2,DecodeSymbol(Tag) RANGE = HIGH - LOW; n = 1; While ( (tag - LOW) / RANGE = CDF(n) ) n+; HIGH = LOW + RANGE * CDF(n);LOW = LOW + RANGE * CDF(n-1);/keep scaling before decoding next symbolwhile LOW, HIGH in 0, 0.5) or 0.5, 1) scale LOW, HIGH by E1 or E2 ruleLeft shift Tag and read one more
22、 bit to LSBreturn n; ,(For floating-point implementation),Outline,Review Integer Implementation Integer representation E3 Scaling Complete Algorithm Minimum word length Binary Arithmetic Coding Adaptive Arithmetic Coding Applications JBIG, H.264, JPEG 2000,Integer Implementation,Old formulas:,HIGH L
23、OW + RANGE * CDF(n); LOW LOW + RANGE * CDF(n-1);,Integer approximation of CDF ( ): The number of occurrence of each symbol is usually collected by a counter. Allow adaptive arithmetic coding,Integer Implementation,HIGH LOW + RANGE * CDF(n); LOW LOW + RANGE * CDF(n-1);,Why + 1 in RANGE and 1 in HIGH?
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ARITHMETICCODINGADDITIONALMATERIALSPRING2015PPT

链接地址:http://www.mydoc123.com/p-378565.html