codec/h264/h264dec: got rid of unneeded closure and renamed suffix to s

This commit is contained in:
Saxon 2019-08-15 08:04:40 +09:30
parent 08d3f6c3d1
commit 4a2c3487c7
1 changed files with 7 additions and 8 deletions

View File

@ -796,8 +796,7 @@ func unaryExpGolombBinarization(v, uCoff, k int, signedValFlag bool) ([]int, err
// using the the algorithm as described by pseudo code 9-6 in section 9.3.2.3. // using the the algorithm as described by pseudo code 9-6 in section 9.3.2.3.
// TODO: could probably reduce allocations. // TODO: could probably reduce allocations.
func suffix(v, uCoff, k int, signedValFlag bool) []int { func suffix(v, uCoff, k int, signedValFlag bool) []int {
var suffix []int var s []int
put := func(p int) { suffix = append(suffix, p) }
if absi(v) >= uCoff { if absi(v) >= uCoff {
sufS := absi(v) - uCoff sufS := absi(v) - uCoff
@ -805,13 +804,13 @@ func suffix(v, uCoff, k int, signedValFlag bool) []int {
for { for {
if sufS >= (1 << uint(k)) { if sufS >= (1 << uint(k)) {
put(1) s = append(s, 1)
sufS = sufS - (1 << uint(k)) sufS = sufS - (1 << uint(k))
k++ k++
} else { } else {
put(0) s = append(s, 0)
for k = k - 1; k >= 0; k-- { for k = k - 1; k >= 0; k-- {
put((sufS >> uint(k)) & 1) s = append(s, (sufS>>uint(k))&1)
} }
stop = true stop = true
} }
@ -823,11 +822,11 @@ func suffix(v, uCoff, k int, signedValFlag bool) []int {
if signedValFlag && v != 0 { if signedValFlag && v != 0 {
if v > 0 { if v > 0 {
put(0) s = append(s, 0)
} else { } else {
put(1) s = append(s, 1)
} }
} }
return suffix return s
} }