这是indexloc提供的服务,不要输入任何密码
Skip to content

Decoder status differences between version 0.7.0 and 0.11.1 #4400

@radarhere

Description

@radarhere

Hi. Hopefully this is a simple question. With JPEG XL 0.7.0, I find I receive different output from JxlDecoderProcessInput() than I do with JPEG XL 0.11.1.

I've tried to simplify the code like so, running over a test image.

JxlBasicInfo basic_info;
uint8_t *jxl_icc;
size_t jxl_icc_len;
Py_ssize_t n_frames = 0;

Py_ssize_t jxl_data_len = _tmp_jxl_data_len;
uint8_t *jxl_data = malloc(jxl_data_len);
memcpy(jxl_data, _tmp_jxl_data, jxl_data_len);

JxlThreadParallelRunnerCreate(NULL, 4);
JxlDecoder *decoder = JxlDecoderCreate(NULL);

JxlDecoderStatus status = JxlDecoderSubscribeEvents(decoder, JXL_DEC_BASIC_INFO | JXL_DEC_COLOR_ENCODING | JXL_DEC_FRAME | JXL_DEC_FULL_IMAGE);

status = JxlDecoderSetDecompressBoxes(decoder, JXL_TRUE);

status = JxlDecoderSetInput(decoder, jxl_data, jxl_data_len);
JxlDecoderCloseInput(decoder);

// decode everything up to the first frame
do {
	status = JxlDecoderProcessInput(decoder);
	printf("Status during first frame: %d\n", status);

	if (status == JXL_DEC_BASIC_INFO) {
		status = JxlDecoderGetBasicInfo(decoder, &basic_info);
	} else if (status == JXL_DEC_COLOR_ENCODING) {
		status = JxlDecoderGetICCProfileSize(
			decoder,
#if JPEGXL_MINOR_VERSION < 9
			NULL,
#endif
			JXL_COLOR_PROFILE_TARGET_DATA,
			&jxl_icc_len
		);

		jxl_icc = malloc(jxl_icc_len);
		status = JxlDecoderGetColorAsICCProfile(
			decoder,
#if JPEGXL_MINOR_VERSION < 9
			NULL,
#endif
			JXL_COLOR_PROFILE_TARGET_DATA,
			jxl_icc,
			jxl_icc_len
		);
	}
} while (status != JXL_DEC_FRAME);

if (basic_info.have_animation) {
	while (status != JXL_DEC_SUCCESS) {
		status = JxlDecoderProcessInput(decoder);

		if (status == JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
			JxlDecoderSkipCurrentFrame(decoder);
			n_frames++;
		}
	}
	JxlDecoderRewind(decoder);
}

JxlFrameHeader fhdr = {};

while (status != JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
	status = JxlDecoderProcessInput(decoder);
	printf("Status: %d\n", status);

	if (status == JXL_DEC_SUCCESS) {
		printf("Done with JXL_DEC_SUCCESS\n");
		Py_RETURN_NONE;
	} else if (status == JXL_DEC_NEED_MORE_INPUT) {
		status = JxlDecoderSetInput(decoder, jxl_data, jxl_data_len);
		JxlDecoderCloseInput(decoder);
	} else if (status == JXL_DEC_FRAME) {
		status = JxlDecoderGetFrameHeader(decoder, &fhdr);
		continue;
	}
}
printf("Done\n");

Is there anything in the above block that I'm obviously doing wrong for 0.7.0?

With JPEG XL 0.11.1, I'm able to receive JXL_DEC_BASIC_INFO from the second frame in the image. With JPEG XL 0.7.0, it instead just gives me JXL_DEC_SUCCESS. I presume there should be some way that 0.7.0 can still get information about subsequent frames.

0.7.0

Status during first frame: 64
Status during first frame: 256
Status during first frame: 1024
Status: 2
Status: 0
Done with JXL_DEC_SUCCESS

0.11.1

Status during first frame: 64
Status during first frame: 256
Status during first frame: 1024
Status: 2
Status: 64
Status: 256
Status: 1024
Status: 5
Done

Thanks for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions