Browse Source

Update reference types

pull/643/head
James Jackson-South 8 years ago
parent
commit
bdd3291d69
  1. 23
      src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/ScanDecoder.cs

23
src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/ScanDecoder.cs

@ -4,8 +4,7 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
@ -64,7 +63,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
this.dctZigZag = ZigZag.CreateUnzigTable(); this.dctZigZag = ZigZag.CreateUnzigTable();
this.stream = stream; this.stream = stream;
this.components = components; this.components = components;
this.marker = PdfJsJpegConstants.Markers.Prefix; this.marker = JpegConstants.Markers.XFF;
this.componentIndex = componentIndex; this.componentIndex = componentIndex;
this.componentsLength = componentsLength; this.componentsLength = componentsLength;
this.restartInterval = restartInterval; this.restartInterval = restartInterval;
@ -532,7 +531,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
this.GrowBufferUnsafe(); this.GrowBufferUnsafe();
} }
uint k = this.Lrot(this.codeBuffer, n); uint k = this.LRot(this.codeBuffer, n);
this.codeBuffer = k & ~Bmask[n]; this.codeBuffer = k & ~Bmask[n];
k &= Bmask[n]; k &= Bmask[n];
this.codeBits -= n; this.codeBits -= n;
@ -554,17 +553,18 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
return (int)(k & 0x80000000); return (int)(k & 0x80000000);
} }
[MethodImpl(MethodImplOptions.NoInlining)]
private void GrowBufferUnsafe() private void GrowBufferUnsafe()
{ {
do do
{ {
// TODO: EOF // TODO: EOF
int b = this.nomore ? 0 : this.stream.ReadByte(); int b = this.nomore ? 0 : this.stream.ReadByte();
if (b == PdfJsJpegConstants.Markers.Prefix) if (b == JpegConstants.Markers.XFF)
{ {
long position = this.stream.Position - 1; long position = this.stream.Position - 1;
int c = this.stream.ReadByte(); int c = this.stream.ReadByte();
while (c == PdfJsJpegConstants.Markers.Prefix) while (c == JpegConstants.Markers.XFF)
{ {
if (c != 0) if (c != 0)
{ {
@ -586,6 +586,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
while (this.codeBits <= 24); while (this.codeBits <= 24);
} }
// TODO: Split into Fast/Slow and inline Fast
private int DecodeHuffman(ref PdfJsHuffmanTable table) private int DecodeHuffman(ref PdfJsHuffmanTable table)
{ {
this.CheckBits(); this.CheckBits();
@ -651,8 +652,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
this.GrowBufferUnsafe(); this.GrowBufferUnsafe();
} }
int sgn = (int)((int)this.codeBuffer >> 31); int sgn = (int)this.codeBuffer >> 31;
uint k = this.Lrot(this.codeBuffer, n); uint k = this.LRot(this.codeBuffer, n);
this.codeBuffer = k & ~Bmask[n]; this.codeBuffer = k & ~Bmask[n];
k &= Bmask[n]; k &= Bmask[n];
this.codeBits -= n; this.codeBits -= n;
@ -675,7 +676,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private uint Lrot(uint x, int y) private uint LRot(uint x, int y)
{ {
return (x << y) | (x >> (32 - y)); return (x << y) | (x >> (32 - y));
} }
@ -683,7 +684,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool IsRestartMarker(byte x) private bool IsRestartMarker(byte x)
{ {
return x >= PdfJsJpegConstants.Markers.RST0 && x <= PdfJsJpegConstants.Markers.RST7; return x >= JpegConstants.Markers.RST0 && x <= JpegConstants.Markers.RST7;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -699,7 +700,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
c.DcPredictor = 0; c.DcPredictor = 0;
} }
this.marker = PdfJsJpegConstants.Markers.Prefix; this.marker = JpegConstants.Markers.XFF;
this.eobrun = 0; this.eobrun = 0;
// No more than 1<<31 MCUs if no restartInterval? that's plenty safe since we don't even allow 1<<30 pixels // No more than 1<<31 MCUs if no restartInterval? that's plenty safe since we don't even allow 1<<30 pixels

Loading…
Cancel
Save