Skip to content

Commit e2438b1

Browse files
authored
Merge branch 'master' into bp/tiffjpegcompression
2 parents 3215c45 + 5d82124 commit e2438b1

File tree

11 files changed

+180
-32
lines changed

11 files changed

+180
-32
lines changed

src/ImageSharp/Formats/Jpeg/JpegConstants.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ internal static class Markers
133133
/// </summary>
134134
public const byte APP15 = 0xEF;
135135

136+
/// <summary>
137+
/// Define arithmetic coding conditioning marker.
138+
/// </summary>
139+
public const byte DAC = 0xCC;
140+
136141
/// <summary>
137142
/// The text comment marker
138143
/// </summary>
@@ -173,6 +178,56 @@ internal static class Markers
173178
/// </summary>
174179
public const byte SOF2 = 0xC2;
175180

181+
/// <summary>
182+
/// Start of Frame marker, non differential lossless, Huffman coding.
183+
/// </summary>
184+
public const byte SOF3 = 0xC3;
185+
186+
/// <summary>
187+
/// Start of Frame marker, differential, Huffman coding, Differential sequential DCT.
188+
/// </summary>
189+
public const byte SOF5 = 0xC5;
190+
191+
/// <summary>
192+
/// Start of Frame marker, differential, Huffman coding, Differential progressive DCT.
193+
/// </summary>
194+
public const byte SOF6 = 0xC6;
195+
196+
/// <summary>
197+
/// Start of Frame marker, differential lossless, Huffman coding.
198+
/// </summary>
199+
public const byte SOF7 = 0xC7;
200+
201+
/// <summary>
202+
/// Start of Frame marker, non-differential, arithmetic coding, Extended sequential DCT.
203+
/// </summary>
204+
public const byte SOF9 = 0xC9;
205+
206+
/// <summary>
207+
/// Start of Frame marker, non-differential, arithmetic coding, Progressive DCT.
208+
/// </summary>
209+
public const byte SOF10 = 0xCA;
210+
211+
/// <summary>
212+
/// Start of Frame marker, non-differential, arithmetic coding, Lossless (sequential).
213+
/// </summary>
214+
public const byte SOF11 = 0xCB;
215+
216+
/// <summary>
217+
/// Start of Frame marker, differential, arithmetic coding, Differential sequential DCT.
218+
/// </summary>
219+
public const byte SOF13 = 0xCD;
220+
221+
/// <summary>
222+
/// Start of Frame marker, differential, arithmetic coding, Differential progressive DCT.
223+
/// </summary>
224+
public const byte SOF14 = 0xCE;
225+
226+
/// <summary>
227+
/// Start of Frame marker, differential, arithmetic coding, Differential lossless (sequential).
228+
/// </summary>
229+
public const byte SOF15 = 0xCF;
230+
176231
/// <summary>
177232
/// Define Huffman Table(s)
178233
/// <remarks>

src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,28 @@ internal void ParseStream(BufferedReadStream stream, HuffmanScanDecoder scanDeco
309309
this.ProcessStartOfFrameMarker(stream, remaining, fileMarker, metadataOnly);
310310
break;
311311

312+
case JpegConstants.Markers.SOF5:
313+
JpegThrowHelper.ThrowNotSupportedException("Decoding jpeg files with differential sequential DCT is not supported.");
314+
break;
315+
316+
case JpegConstants.Markers.SOF6:
317+
JpegThrowHelper.ThrowNotSupportedException("Decoding jpeg files with differential progressive DCT is not supported.");
318+
break;
319+
320+
case JpegConstants.Markers.SOF3:
321+
case JpegConstants.Markers.SOF7:
322+
JpegThrowHelper.ThrowNotSupportedException("Decoding lossless jpeg files is not supported.");
323+
break;
324+
325+
case JpegConstants.Markers.SOF9:
326+
case JpegConstants.Markers.SOF10:
327+
case JpegConstants.Markers.SOF11:
328+
case JpegConstants.Markers.SOF13:
329+
case JpegConstants.Markers.SOF14:
330+
case JpegConstants.Markers.SOF15:
331+
JpegThrowHelper.ThrowNotSupportedException("Decoding jpeg files with arithmetic coding is not supported.");
332+
break;
333+
312334
case JpegConstants.Markers.SOS:
313335
if (!metadataOnly)
314336
{
@@ -388,6 +410,10 @@ internal void ParseStream(BufferedReadStream stream, HuffmanScanDecoder scanDeco
388410
case JpegConstants.Markers.COM:
389411
stream.Skip(remaining);
390412
break;
413+
414+
case JpegConstants.Markers.DAC:
415+
JpegThrowHelper.ThrowNotSupportedException("Decoding jpeg files with arithmetic coding is not supported.");
416+
break;
391417
}
392418
}
393419

src/ImageSharp/Formats/Jpeg/JpegThrowHelper.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
88
{
99
internal static class JpegThrowHelper
1010
{
11+
/// <summary>
12+
/// Cold path optimization for throwing <see cref="NotSupportedException"/>'s.
13+
/// </summary>
14+
/// <param name="errorMessage">The error message for the exception.</param>
15+
[MethodImpl(InliningOptions.ColdPath)]
16+
public static void ThrowNotSupportedException(string errorMessage) => throw new NotSupportedException(errorMessage);
17+
1118
/// <summary>
1219
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s.
1320
/// </summary>

0 commit comments

Comments
 (0)