|
|
|
@ -235,6 +235,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort |
|
|
|
|
|
|
|
// Check for the Start Of Image marker.
|
|
|
|
this.InputProcessor.ReadFull(this.Temp, 0, 2); |
|
|
|
|
|
|
|
if (this.Temp[0] != OrigJpegConstants.Markers.XFF || this.Temp[1] != OrigJpegConstants.Markers.SOI) |
|
|
|
{ |
|
|
|
throw new ImageFormatException("Missing SOI marker."); |
|
|
|
@ -247,6 +248,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort |
|
|
|
while (processBytes) |
|
|
|
{ |
|
|
|
this.InputProcessor.ReadFull(this.Temp, 0, 2); |
|
|
|
|
|
|
|
if (this.InputProcessor.ReachedEOF) |
|
|
|
{ |
|
|
|
// We've reached the end of the stream.
|
|
|
|
processBytes = false; |
|
|
|
} |
|
|
|
|
|
|
|
while (this.Temp[0] != 0xff) |
|
|
|
{ |
|
|
|
// Strictly speaking, this is a format error. However, libjpeg is
|
|
|
|
@ -282,6 +290,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort |
|
|
|
// Section B.1.1.2 says, "Any marker may optionally be preceded by any
|
|
|
|
// number of fill bytes, which are bytes assigned code X'FF'".
|
|
|
|
marker = this.InputProcessor.ReadByte(); |
|
|
|
|
|
|
|
if (this.InputProcessor.ReachedEOF) |
|
|
|
{ |
|
|
|
// We've reached the end of the stream.
|
|
|
|
processBytes = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// End Of Image.
|
|
|
|
@ -388,15 +403,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort |
|
|
|
{ |
|
|
|
this.InputProcessor.Skip(remaining); |
|
|
|
} |
|
|
|
else if (marker < OrigJpegConstants.Markers.SOF0) |
|
|
|
{ |
|
|
|
// See Table B.1 "Marker code assignments".
|
|
|
|
throw new ImageFormatException("Unknown marker"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new ImageFormatException("Unknown marker"); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|