mirror of https://bitbucket.org/ausocean/av.git
codec/h264/h264dec: merged in master and removed additional binToSlice func
This commit is contained in:
parent
e839a8ae57
commit
9239676214
|
@ -10,7 +10,6 @@ package h264dec
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
|
@ -122,34 +121,3 @@ func TestNewPPS(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// binToSlice is a helper function to convert a string of binary into a
|
||||
// corresponding byte slice, e.g. "0100 0001 1000 1100" => {0x41,0x8c}.
|
||||
// Spaces in the string are ignored.
|
||||
func binToSlice(s string) ([]byte, error) {
|
||||
var (
|
||||
a byte = 0x80
|
||||
cur byte
|
||||
bytes []byte
|
||||
)
|
||||
|
||||
for _, c := range s {
|
||||
switch c {
|
||||
case ' ':
|
||||
continue
|
||||
case '1':
|
||||
cur |= a
|
||||
case '0':
|
||||
default:
|
||||
return nil, errors.New("invalid binary string")
|
||||
}
|
||||
|
||||
a >>= 1
|
||||
if a == 0 {
|
||||
bytes = append(bytes, cur)
|
||||
cur = 0
|
||||
a = 0x80
|
||||
}
|
||||
}
|
||||
return bytes, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue