diff --git a/src/codecs/jpeg/encoder.rs b/src/codecs/jpeg/encoder.rs index 5af0433809..6a16365c81 100644 --- a/src/codecs/jpeg/encoder.rs +++ b/src/codecs/jpeg/encoder.rs @@ -789,11 +789,11 @@ fn rgb_to_ycbcr(pixel: P) -> (u8, u8, u8) { const C_YR: i32 = 19595; // 0.29900 = 19595 * 2^-16 const C_YG: i32 = 38469; // 0.58700 = 38469 * 2^-16 const C_YB: i32 = 7471; // 0.11400 = 7471 * 2^-16 - const Y_ROUNDING: i32 = 1 << 15; // + 0.5 to perform rounding shift right in-place + const Y_ROUNDING: i32 = (1 << 15) - 1; // + 0.5 to perform rounding shift right in-place const C_UR: i32 = 11059; // 0.16874 = 11059 * 2^-16 const C_UG: i32 = 21709; // 0.33126 = 21709 * 2^-16 const C_UB: i32 = 32768; // 0.5 = 32768 * 2^-16 - const UV_BIAS_ROUNDING: i32 = (128 * (1 << 16)) + (1 << 15); // 128 + 0.5 = ((128 * (1 << 16)) + (1 << 15)) * 2^-16 ; + 0.5 to perform rounding shift right in-place + const UV_BIAS_ROUNDING: i32 = (128 * (1 << 16)) + ((1 << 15) - 1); // 128 + 0.5 = ((128 * (1 << 16)) + ((1 << 15) - 1)) * 2^-16 ; + 0.5 to perform rounding shift right in-place const C_VR: i32 = C_UB; // 0.5 = 32768 * 2^-16 const C_VG: i32 = 27439; // 0.41869 = 27439 * 2^-16 const C_VB: i32 = 5329; // 0.08131409 = 5329 * 2^-16 @@ -897,6 +897,7 @@ mod tests { // note that, even with the encode quality set to 100, we do not get the same image // back. Therefore, we're going to assert that it's at least red-ish: assert_eq!(3, decoded.len()); + println!("{:?}", &decoded[0..3]); assert!(decoded[0] > 0x80); assert!(decoded[1] < 0x80); assert!(decoded[2] < 0x80);