Skip to content

Commit

Permalink
fix jpeg padding 0xff bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
shouldend committed Oct 9, 2020
1 parent 2be7788 commit 5b1aea6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/image/jpeg/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ func (d *decoder) processSOS(n int) error {
return err
}

// padding 0xff bytes, skip and rewrite tmp[1] until not equals to 0xff
for d.tmp[0] == 0xff && d.tmp[1] == 0xff {
if err := d.readFull(d.tmp[1:2]); err != nil {
return err
}
}
// Section F.1.2.3 says that "Byte alignment of markers is
// achieved by padding incomplete bytes with 1-bits. If padding
// with 1-bits creates a X’FF’ value, a zero byte is stuffed
Expand Down

0 comments on commit 5b1aea6

Please sign in to comment.