Add framing code
Fix the overflow bug in frame calculation
Add get-all-frame framing function
Add inverse framing
Small variable rename: we use s to represent "segment"
Merge branch 'framing' into slave