codec/h264/lex.go: simplified return logic

This commit is contained in:
Saxon 2020-01-22 13:08:02 +10:30
parent 2d2e1b0ad1
commit bf289221de
1 changed files with 3 additions and 11 deletions

View File

@ -67,16 +67,12 @@ func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
copy(buf, h264Prefix[:]) copy(buf, h264Prefix[:])
writeOut := false writeOut := false
outer:
for { for {
var b byte var b byte
var err error var err error
buf, b, err = c.ScanUntil(buf, 0x00) buf, b, err = c.ScanUntil(buf, 0x00)
if err != nil { if err != nil {
if err != io.EOF { return err
return err
}
break
} }
for n := 1; b == 0x0 && n < 4; n++ { for n := 1; b == 0x0 && n < 4; n++ {
@ -85,7 +81,7 @@ outer:
if err != io.EOF { if err != io.EOF {
return err return err
} }
break outer return io.ErrUnexpectedEOF
} }
buf = append(buf, b) buf = append(buf, b)
@ -110,7 +106,7 @@ outer:
if err != io.EOF { if err != io.EOF {
return err return err
} }
break outer return io.ErrUnexpectedEOF
} }
buf = append(buf, b) buf = append(buf, b)
@ -128,8 +124,4 @@ outer:
} }
} }
} }
if len(buf) == len(h264Prefix) {
return io.EOF
}
return io.ErrUnexpectedEOF
} }