Skip to content

Commit 997cc8f

Browse files
LucasCholletnico
authored andcommitted
LibGfx/JPEG: Stop clamping in the RGB to YCbCr conversion code
No observed behavior change with both `test-jpeg-roundtrip` and the output of: ``` image -o buggie.jpg Base/res/graphics/buggie.png ```
1 parent c0e5153 commit 997cc8f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ class JPEGEncodingContext {
186186
// Conversion from YCbCr to RGB isn't specified in the first JPEG specification but in the JFIF extension:
187187
// See: https://www.itu.int/rec/dologin_pub.asp?lang=f&id=T-REC-T.871-201105-I!!PDF-E&type=items
188188
// 7 - Conversion to and from RGB
189-
auto const y_ = clamp(0.299f * r + 0.587f * g + 0.114f * b, 0, 255);
190-
auto const cb = clamp(-0.1687f * r - 0.3313f * g + 0.5f * b + 128, 0, 255);
191-
auto const cr = clamp(0.5f * r - 0.4187f * g - 0.0813f * b + 128, 0, 255);
189+
auto const y_ = 0.299f * r + 0.587f * g + 0.114f * b;
190+
auto const cb = -0.1687f * r - 0.3313f * g + 0.5f * b + 128;
191+
auto const cr = 0.5f * r - 0.4187f * g - 0.0813f * b + 128;
192192

193193
// A.3.1 - Level shift
194194
macroblock.y[i] = y_ - 128;

0 commit comments

Comments
 (0)