Merged in coded-block-binarization (pull request #236)

codec/h264/h264dec/cabacenc.go: added coded block pattern binary string process
This commit is contained in:
Saxon Milton 2019-08-26 07:11:17 +00:00
commit 5ab8deb8a3
1 changed files with 21 additions and 0 deletions

View File

@ -28,6 +28,7 @@ package h264dec
import (
"errors"
"fmt"
"math"
)
@ -220,3 +221,23 @@ func subMbTypeBinString(v, slice int) ([]int, error) {
return nil, errBadSubMbSliceType
}
}
// codedBlockPatternBinString returns the binarization for the syntax element
// coded_block_pattern as defined by section 9.3.2.6 in specifications.
func codedBlockPatternBinString(luma, chroma, arrayType int) ([]int, error) {
p, err := fixedLenBinString(luma, 15)
if err != nil {
return nil, fmt.Errorf("fixed length binarization failed with error: %v", err)
}
if arrayType == 0 || arrayType == 3 {
return p, nil
}
s, err := truncUnaryBinString(chroma, 2)
if err != nil {
return nil, fmt.Errorf("truncated unary binarization failed with error: %v", err)
}
return append(p, s...), nil
}