-
Notifications
You must be signed in to change notification settings - Fork 317
Closed
Description
libjxl sometimes crashes with enc_ans.cc:228: JXL_DASSERT: n <= 255 when encoding lossless monochrome samples at effort 8+.
See inflation/jpegxl-rs#101.
To Reproduce
git clone https://github.com/libjxl/libjxl.git
cd libjxl
git checkout 095f259
./deps.shReplace the contents of cjxl_main.cc by
int main(int, char**) {
JxlEncoderPtr enc = JxlEncoderMake(nullptr);
JxlPixelFormat pixel_format = {1, JXL_TYPE_UINT16, JXL_NATIVE_ENDIAN, 0};
JxlBasicInfo basic_info;
JxlEncoderInitBasicInfo(&basic_info);
basic_info.xsize = 1;
basic_info.ysize = 1;
basic_info.bits_per_sample = 16;
basic_info.uses_original_profile = JXL_TRUE;
basic_info.num_color_channels = pixel_format.num_channels;
if (JXL_ENC_SUCCESS != JxlEncoderSetBasicInfo(enc.get(), &basic_info)) abort();
JxlColorEncoding color_encoding = {};
JXL_BOOL is_gray = TO_JXL_BOOL(pixel_format.num_channels < 3);
JxlColorEncodingSetToSRGB(&color_encoding, is_gray);
if (JXL_ENC_SUCCESS != JxlEncoderSetColorEncoding(enc.get(), &color_encoding)) abort();
JxlEncoderFrameSettings* f = JxlEncoderFrameSettingsCreate(enc.get(), nullptr);
if (JXL_ENC_SUCCESS != JxlEncoderFrameSettingsSetOption(f, JXL_ENC_FRAME_SETTING_EFFORT, 8)) abort();
if (JXL_ENC_SUCCESS != JxlEncoderSetFrameLossless(f, JXL_TRUE)) abort();
uint16_t pixels = 1020;
if (JXL_ENC_SUCCESS != JxlEncoderAddImageFrame(f, &pixel_format, &pixels, 16)) abort();
JxlEncoderCloseInput(enc.get());
std::vector<uint8_t> compressed(1024);
uint8_t* next_out = compressed.data();
size_t avail_out = compressed.size();
JxlEncoderProcessOutput(enc.get(), &next_out, &avail_out);
return EXIT_SUCCESS;
}cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel
build_dbg/tools/cjxlExpected behavior
Silent success instead of:
./lib/jxl/enc_ans.cc:228: JXL_DASSERT: n <= 255
Illegal instruction
Environment
- OS: Linux
- Compiler version: GNU 13.2.0
- CPU type:
x86_64 - cjxl/djxl version string:
v0.12.0 095f259b [AVX2,SSE4,SSE2]
Metadata
Metadata
Assignees
Labels
No labels