codec/h264/h264dec/cavlc.go: removed redundant if checks in parseLevelInformation

This commit is contained in:
Saxon 2019-09-08 13:31:10 +09:30
parent ce803ba488
commit 960d41cb4f
1 changed files with 63 additions and 67 deletions

View File

@ -51,7 +51,6 @@ func parseLevelPrefix(br *bits.BitReader) (int, error) {
func parseLevelInformation(br *bits.BitReader, totalCoeff, trailingOnes int) ([]int, error) { func parseLevelInformation(br *bits.BitReader, totalCoeff, trailingOnes int) ([]int, error) {
var levelVal []int var levelVal []int
var i int var i int
if trailingOnes != 0 {
for ; i < trailingOnes; i++ { for ; i < trailingOnes; i++ {
b, err := br.ReadBits(1) b, err := br.ReadBits(1)
if err != nil { if err != nil {
@ -63,7 +62,6 @@ func parseLevelInformation(br *bits.BitReader, totalCoeff, trailingOnes int) ([]
} }
levelVal = append(levelVal, -1) levelVal = append(levelVal, -1)
} }
}
var suffixLen int var suffixLen int
switch { switch {
@ -75,7 +73,6 @@ func parseLevelInformation(br *bits.BitReader, totalCoeff, trailingOnes int) ([]
return nil, errors.New("invalid TotalCoeff and TrailingOnes combination") return nil, errors.New("invalid TotalCoeff and TrailingOnes combination")
} }
if totalCoeff-trailingOnes != 0 {
for j := 0; j < totalCoeff-trailingOnes; j++ { for j := 0; j < totalCoeff-trailingOnes; j++ {
levelPrefix, err := parseLevelPrefix(br) levelPrefix, err := parseLevelPrefix(br)
if err != nil { if err != nil {
@ -132,6 +129,5 @@ func parseLevelInformation(br *bits.BitReader, totalCoeff, trailingOnes int) ([]
} }
i++ i++
} }
}
return levelVal, nil return levelVal, nil
} }