YAECL Yet Another Entropy Coding Library
1.0.0
pip install yaecl==0.0.1 import yaecl| 平台 | 編碼算法 | 編碼模式 | CDF模式 | CDF精密CTRL | 編解碼器精密CTRL | |
|---|---|---|---|---|---|---|
| yaecl | C ++標頭,Python | AC,蘭斯 | 1x1,1xn,nxn | int(任何w) | 是的 | 是的 |
| 收縮 | 銹,python | 霍夫曼(Huffman),Range,Rans | 1x1,1xn,nxn | 漂浮 | 不 | 不 |
| 沃奇克 | Python(火炬) | 交流 | NXN | Float,INT16 | 不 | 不 |
| Nayuki | C ++,Python,Java | 交流 | 1x1 | Uint32 | 是的 | 是的 |
| ryg_rans | C標題 | 蘭斯 | 1x1 | Uint32 | 是的 | 不 |
| 渦輪 | C/C ++ | 範圍,交流,蘭斯 | 1x1 | Float,INT8/16/32 | 是的 | 是的 |
# include " yaecl.hpp "
using namespace yaecl ; uint32_t cdf_max= ( 1 << 16 );
uint32_t cdf[ 6 ] = { 0 , 0.2 * cdf_max, 0.4 * cdf_max, 0.6 * cdf_max, 0.8 * cdf_max, cdf_max};ArithmeticCodingEncoder< uint64_t , uint32_t > ace=ArithmeticCodingEncoder< uint64_t , uint32_t >( 32 );
for ( int i= 1 ;i<=test_n;i++) ace.encode(i % 5 , cdf, 16 );
ace.flush();
ace.bit_stream.save( " path " ); // optionallyBitStream bs = ace.bit_stream;
// BitStream bs; bs.load("path");
ArithmeticCodingDecoder< uint64_t , uint32_t > acd = ArithmeticCodingDecoder< uint64_t , uint32_t >( 32 , bs);
for ( int i= 1 ;i<=test_n;i++) assert( static_cast < int >(acd.decode( 5 , cdf, 16 )) == i% 5 );mkdir build
cd build
cmake ../ -DPYTHON_EXECUTABLE:FILEPATH= $YOUR_PYTHON_BIN -DPYTHON_INCLUDE_DIR:PATH= $YOUR_PYTHON_INCLUDE -DPYTHON_LIBRARY:FILEPATH= $YOUR_PYTHON_LIB
make -jcmake ../ -DPYTHON_EXECUTABLE:FILEPATH=/home/xx/.conda/envs/yy/bin/python -DPYTHON_INCLUDE_DIR:PATH=/home/xx/.conda/envs/yy/include/python3.10 -DPYTHON_LIBRARY:FILEPATH=/home/xx/.conda/envs/yy/lib/libpython3.10.so import yaecl cnt = 32 * 48 * 320
cdf_max = 2 ** 16
cdf = np . array ([ 0 , 0.2 * cdf_max , 0.4 * cdf_max , 0.6 * cdf_max , 0.8 * cdf_max , cdf_max ], dtype = np . int32 )
# encode symbol by symbol
ac_enc = yaecl . ac_encoder_t ()
for i in range ( cnt ):
ac_enc . encode ( i % 5 , memoryview ( cdf ), 16 )
ac_enc . flush ()
# encode n x 1
sym_b = np . array ([ i % 5 for i in range ( cnt )], dtype = np . int32 )
symd_b = np . array ([ 0 for _ in range ( cnt )], dtype = np . int32 )
ac_enc = yaecl . ac_encoder_t ()
ac_enc . encode_nx1 ( sym_b , memoryview ( cdf ), 16 )
ac_enc . flush ()
# encode n x n
sym_b = np . array ([ i % 5 for i in range ( cnt )], dtype = np . int32 )
cdf_b = np . array ([ cdf for _ in range ( cnt )], dtype = np . int32 )
ac_enc = yaecl . ac_encoder_t ()
ac_enc . encode_nxn ( sym_b , cdf_b , 16 )
ac_enc . flush () # decode 1 x 1
ac_dec = yaecl . ac_decoder_t ( ac_enc . bit_stream )
for i in range ( cnt ):
de_sym = ac_dec . decode ( 5 , memoryview ( cdf ), 16 )
# decode n x n
symd_b = np . array ([ 0 for _ in range ( cnt )], dtype = np . int32 )
ac_dec = yaecl . ac_decoder_t ( ac_enc . bit_stream )
ac_dec . decode_nxn ( 5 , memoryview ( cdf_b ), 16 , memoryview ( symd_b )) @article{xu2022bit,
title={Bit allocation using optimization},
author={Xu, Tongda and Gao, Han and Gao, Chenjian and Pi, Jinyong and Li, Yanghao and Wang, Yuanyuan and Zhu, Ziyu and He, Dailan and Ye, Mao and Qin, Hongwei and others},
journal={arXiv preprint arXiv:2209.09422},
year={2022}
}