Skip to content

Commit

Permalink
Incorporate feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Jul 15, 2024
1 parent 6afef40 commit 4c8dde6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libvips/foreign/jxlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,17 @@ vips_foreign_load_jxl_read_frame(VipsForeignLoadJxl *jxl, VipsImage *frame,
size_t buffer_size;
JxlDecoderStatus status;

if (jxl->frame_no >= frame_no)
return 0;

int skip = frame_no - jxl->frame_no - 1;
if (skip > 0) {
#ifdef DEBUG_VERBOSE
printf("vips_foreign_load_jxl_read_frame: skipping %d frames\n",
skip);
#endif /*DEBUG_VERBOSE*/
JxlDecoderSkipFrames(jxl->decoder, skip);
jxl->frame_no = frame_no - 1;
jxl->frame_no += skip;
}

/* Read to the end of the image.
Expand Down Expand Up @@ -536,7 +539,7 @@ vips_foreign_load_jxl_read_frame(VipsForeignLoadJxl *jxl, VipsImage *frame,
case JXL_DEC_FULL_IMAGE:
/* We decoded the required frame and can return
*/
if (jxl->frame_no == frame_no)
if (jxl->frame_no >= frame_no)
return 0;

break;
Expand Down Expand Up @@ -571,8 +574,7 @@ vips_foreign_load_jxl_generate(VipsRegion *out_region,

g_assert(r->height == 1);

if (jxl->frame_no < frame &&
vips_foreign_load_jxl_read_frame(jxl, jxl->frame, frame))
if (vips_foreign_load_jxl_read_frame(jxl, jxl->frame, frame))
return -1;

memcpy(VIPS_REGION_ADDR(out_region, 0, r->top),
Expand Down

0 comments on commit 4c8dde6

Please sign in to comment.