Skip to content

Commit

Permalink
Fix jxl grey8 compression
Browse files Browse the repository at this point in the history
Summary: This diff fixes the quality issues we noticed with grey8 when using MS-SSIM testing. It's unclear how we got to the non-sense grey8 code, but the MS-SSIM validation doesn't lie: grey8 works now.

Reviewed By: kiminoue7

Differential Revision: D51841807

fbshipit-source-id: a8b26e4ee8d25263cf7d659c5e5fea1dfa430673
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Dec 5, 2023
1 parent 798e3b3 commit 96ec2fe
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions vrs/utils/PixelFrameJxl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,8 @@ bool PixelFrame::readJxlFrame(const vector<uint8_t>& jxlBuf, bool decodePixels)

case JXL_DEC_COLOR_ENCODING: {
JxlColorEncoding colorEncoding;
if (JxlDecoderGetColorAsEncodedProfile(
dec, &format, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &colorEncoding) ==
JXL_DEC_SUCCESS &&
colorEncoding.color_space == JXL_COLOR_SPACE_GRAY) {
colorEncoding.gamma = 0.5;
colorEncoding.transfer_function = JXL_TRANSFER_FUNCTION_GAMMA;
} else {
DEC_CHECK(JxlDecoderGetColorAsEncodedProfile(
dec, &format, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &colorEncoding));
}
DEC_CHECK(JxlDecoderGetColorAsEncodedProfile(
dec, &format, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &colorEncoding));
DEC_CHECK(JxlDecoderSetPreferredColorProfile(dec, &colorEncoding));
} break;

Expand Down Expand Up @@ -334,15 +326,7 @@ bool PixelFrame::jxlCompress(
ENC_CHECK(JxlEncoderSetBasicInfo(enc, &basic_info));

JxlColorEncoding color_encoding = {};
if (basic_info.num_color_channels > 1) {
JxlColorEncodingSetToLinearSRGB(
&color_encoding,
/*is_gray=*/pixel_format.num_channels < 3);
} else {
JxlColorEncodingSetToSRGB(
&color_encoding,
/*is_gray=*/pixel_format.num_channels < 3);
}
JxlColorEncodingSetToLinearSRGB(&color_encoding, basic_info.num_color_channels < 2);
ENC_CHECK(JxlEncoderSetColorEncoding(enc, &color_encoding));

JxlEncoderFrameSettings* settings = JxlEncoderFrameSettingsCreate(enc, nullptr);
Expand Down

0 comments on commit 96ec2fe

Please sign in to comment.