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[:])
writeOut := false
outer:
for {
var b byte
var err error
buf, b, err = c.ScanUntil(buf, 0x00)
if err != nil {
if err != io.EOF {
return err
}
break
return err
}
for n := 1; b == 0x0 && n < 4; n++ {
@ -85,7 +81,7 @@ outer:
if err != io.EOF {
return err
}
break outer
return io.ErrUnexpectedEOF
}
buf = append(buf, b)
@ -110,7 +106,7 @@ outer:
if err != io.EOF {
return err
}
break outer
return io.ErrUnexpectedEOF
}
buf = append(buf, b)
@ -128,8 +124,4 @@ outer:
}
}
}
if len(buf) == len(h264Prefix) {
return io.EOF
}
return io.ErrUnexpectedEOF
}