Browse Source

Simplified quantization table scaling in the encoder

pull/1706/head
Dmitry Pentin 5 years ago
parent
commit
b16301b631
  1. 15
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

15
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

@ -702,19 +702,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
for (int j = 0; j < Block8x8F.Size; j++)
{
int x = unscaledQuant[j];
x = ((x * scale) + 50) / 100;
if (x < 1)
{
x = 1;
}
if (x > 255)
{
x = 255;
}
quant[j] = x;
int scaled = ((unscaledQuant[j] * scale) + 50) / 100;
quant[j] = Math.Clamp(scaled, 1, 255);
}
}
}

Loading…
Cancel
Save