forked from old/legacy-imlib2
multiframe: Tweaks around frame number handling
This commit is contained in:
parent
0071544859
commit
6df68e3e2e
|
@ -140,10 +140,10 @@ struct _ImlibImage {
|
|||
char has_alpha;
|
||||
char rsvd[3];
|
||||
|
||||
int frame;
|
||||
int canvas_w; /* Canvas size */
|
||||
int canvas_h;
|
||||
int frame_count; /* Number of frames */
|
||||
int frame_num; /* Current frame */
|
||||
int frame_x; /* Frame origin */
|
||||
int frame_y;
|
||||
int frame_flags; /* Frame flags */
|
||||
|
|
|
@ -683,7 +683,7 @@ imlib_image_get_frame_info(Imlib_Frame_Info * info)
|
|||
|
||||
info->loop_count = im->loop_count;
|
||||
info->frame_count = im->frame_count;
|
||||
info->frame_num = im->frame_num;
|
||||
info->frame_num = im->frame;
|
||||
info->canvas_w = im->canvas_w ? im->canvas_w : im->w;
|
||||
info->canvas_h = im->canvas_h ? im->canvas_h : im->h;
|
||||
info->frame_x = im->frame_x;
|
||||
|
|
|
@ -220,19 +220,20 @@ __imlib_FindCachedImage(const char *file, int frame)
|
|||
for (im = images, im_prev = NULL; im; im_prev = im, im = im->next)
|
||||
{
|
||||
/* if the filenames match and it's valid */
|
||||
if (!strcmp(file, im->file) && !IM_FLAG_ISSET(im, F_INVALID) &&
|
||||
frame == im->frame_num)
|
||||
if (strcmp(file, im->file) || IM_FLAG_ISSET(im, F_INVALID))
|
||||
continue;
|
||||
if (frame != im->frame)
|
||||
continue;
|
||||
|
||||
/* move the image to the head of the image list */
|
||||
if (im_prev)
|
||||
{
|
||||
/* move the image to the head of the image list */
|
||||
if (im_prev)
|
||||
{
|
||||
im_prev->next = im->next;
|
||||
im->next = images;
|
||||
images = im;
|
||||
}
|
||||
DP(" got %p: '%s' frame %d\n", im, im->fi->name, im->frame_num);
|
||||
return im;
|
||||
im_prev->next = im->next;
|
||||
im->next = images;
|
||||
images = im;
|
||||
}
|
||||
DP(" got %p: '%s' frame %d\n", im, im->fi->name, im->frame);
|
||||
return im;
|
||||
}
|
||||
DP(" got none\n");
|
||||
return NULL;
|
||||
|
@ -242,7 +243,7 @@ __imlib_FindCachedImage(const char *file, int frame)
|
|||
static void
|
||||
__imlib_AddImageToCache(ImlibImage * im)
|
||||
{
|
||||
DP("%s: %p: '%s' frame %d\n", __func__, im, im->fi->name, im->frame_num);
|
||||
DP("%s: %p: '%s' frame %d\n", __func__, im, im->fi->name, im->frame);
|
||||
im->next = images;
|
||||
images = im;
|
||||
}
|
||||
|
@ -254,7 +255,7 @@ __imlib_RemoveImageFromCache(ImlibImage * im_del)
|
|||
ImlibImage *im, *im_prev;
|
||||
|
||||
im = im_del;
|
||||
DP("%s: %p: '%s' frame %d\n", __func__, im, im->fi->name, im->frame_num);
|
||||
DP("%s: %p: '%s' frame %d\n", __func__, im, im->fi->name, im->frame);
|
||||
|
||||
for (im = images, im_prev = NULL; im; im_prev = im, im = im->next)
|
||||
{
|
||||
|
@ -380,8 +381,8 @@ __imlib_LoadImageWrapper(const ImlibLoader * l, ImlibImage * im, int load_data)
|
|||
{
|
||||
int rc;
|
||||
|
||||
DP("%s: fmt='%s' file='%s'(%s), imm=%d\n", __func__,
|
||||
l->name, im->file, im->fi->name, load_data);
|
||||
DP("%s: fmt='%s' file='%s'(%s) frame=%d, imm=%d\n", __func__,
|
||||
l->name, im->file, im->fi->name, im->frame, load_data);
|
||||
|
||||
#if IMLIB2_DEBUG
|
||||
unsigned int t0 = __imlib_time_us();
|
||||
|
@ -548,7 +549,7 @@ __imlib_LoadImage(const char *file, ImlibLoadArgs * ila)
|
|||
im = __imlib_ProduceImage();
|
||||
im->file = strdup(file);
|
||||
im->key = im_key;
|
||||
im->frame_num = ila->frame;
|
||||
im->frame = ila->frame;
|
||||
|
||||
if (__imlib_ImageFileContextPush(im, true, im_file ? im_file : im->file) ||
|
||||
__imlib_FileContextOpen(im->fi, ila->fp, ila->fdata, st.st_size))
|
||||
|
|
|
@ -51,10 +51,10 @@ struct _ImlibImage {
|
|||
char has_alpha;
|
||||
char rsvd[3];
|
||||
|
||||
int frame;
|
||||
int canvas_w; /* Canvas size */
|
||||
int canvas_h;
|
||||
int frame_count; /* Number of frames */
|
||||
int frame_num; /* Current frame */
|
||||
int frame_x; /* Frame origin */
|
||||
int frame_y;
|
||||
int frame_flags; /* Frame flags */
|
||||
|
|
|
@ -84,10 +84,9 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
transp = -1;
|
||||
fcount = 0;
|
||||
frame = 1;
|
||||
if (im->frame_num > 0)
|
||||
frame = im->frame;
|
||||
if (frame > 0)
|
||||
{
|
||||
frame = im->frame_num;
|
||||
im->frame_count = gif->ImageCount;
|
||||
im->loop_count = 0; /* Loop forever */
|
||||
if (im->frame_count > 1)
|
||||
|
@ -137,7 +136,7 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
fcount += 1;
|
||||
|
||||
if (gif->ImageCount != frame)
|
||||
if (frame > 0 && gif->ImageCount != frame)
|
||||
{
|
||||
int size = 0;
|
||||
GifByteType *data;
|
||||
|
@ -204,7 +203,7 @@ _load(ImlibImage * im, int load_data)
|
|||
}
|
||||
|
||||
/* Break if no specific frame was requested */
|
||||
if (im->frame_num == 0)
|
||||
if (frame == 0)
|
||||
break;
|
||||
}
|
||||
else if (rec == EXTENSION_RECORD_TYPE)
|
||||
|
|
|
@ -303,10 +303,9 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
rc = LOAD_BADIMAGE; /* Format accepted */
|
||||
|
||||
frame = 0; /* Select default */
|
||||
if (im->frame_num > 0)
|
||||
frame = im->frame;
|
||||
if (frame > 0)
|
||||
{
|
||||
frame = im->frame_num;
|
||||
im->frame_count = ico.idir.icons;
|
||||
|
||||
if (frame > 1 && frame > im->frame_count)
|
||||
|
|
|
@ -47,7 +47,7 @@ _load(ImlibImage * im, int load_data)
|
|||
JxlDecoder *dec;
|
||||
JxlBasicInfo info;
|
||||
JxlFrameHeader fhdr;
|
||||
int delay_unit;
|
||||
int frame, delay_unit;
|
||||
|
||||
#if MAX_RUNNERS > 0
|
||||
size_t n_runners;
|
||||
|
@ -99,6 +99,7 @@ _load(ImlibImage * im, int load_data)
|
|||
if (jst != JXL_DEC_SUCCESS)
|
||||
goto quit;
|
||||
|
||||
frame = im->frame;
|
||||
delay_unit = 0;
|
||||
|
||||
for (;;)
|
||||
|
@ -136,12 +137,8 @@ _load(ImlibImage * im, int load_data)
|
|||
im->h = info.ysize;
|
||||
im->has_alpha = info.alpha_bits > 0;
|
||||
|
||||
int frame;
|
||||
|
||||
frame = 1;
|
||||
if (im->frame_num > 0)
|
||||
if (frame > 0)
|
||||
{
|
||||
frame = im->frame_num;
|
||||
if (info.have_animation)
|
||||
{
|
||||
im->frame_count = 1234567890; // FIXME - Hack
|
||||
|
@ -158,16 +155,16 @@ _load(ImlibImage * im, int load_data)
|
|||
if (frame > 1 && im->frame_count > 0
|
||||
&& frame > im->frame_count)
|
||||
QUIT_WITH_RC(LOAD_BADFRAME);
|
||||
|
||||
if (frame > 1)
|
||||
{
|
||||
/* Fast forward to desired frame */
|
||||
JxlDecoderSkipFrames(dec, frame - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!load_data)
|
||||
QUIT_WITH_RC(LOAD_SUCCESS);
|
||||
|
||||
if (frame > 1)
|
||||
{
|
||||
/* Fast forward to desired frame */
|
||||
JxlDecoderSkipFrames(dec, frame - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case JXL_DEC_NEED_IMAGE_OUT_BUFFER:
|
||||
|
@ -183,7 +180,7 @@ _load(ImlibImage * im, int load_data)
|
|||
case JXL_DEC_FRAME:
|
||||
JxlDecoderGetFrameHeader(dec, &fhdr);
|
||||
if (fhdr.is_last)
|
||||
im->frame_count = im->frame_num;
|
||||
im->frame_count = frame;
|
||||
im->frame_delay = fhdr.duration * delay_unit;
|
||||
D("Frame duration=%d tc=%08x nl=%d last=%d\n",
|
||||
im->frame_delay, fhdr.timecode, fhdr.name_length, fhdr.is_last);
|
||||
|
|
|
@ -337,8 +337,8 @@ _load(ImlibImage * im, int load_data)
|
|||
png_set_progressive_read_fn(png_ptr, &ctx,
|
||||
info_callback, row_callback, NULL);
|
||||
|
||||
frame = im->frame_num;
|
||||
if (im->frame_num <= 0)
|
||||
frame = im->frame;
|
||||
if (frame <= 0)
|
||||
goto scan_done;
|
||||
|
||||
/* Animation info requested. Look it up to find the frame's
|
||||
|
|
|
@ -46,16 +46,19 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
rc = LOAD_BADIMAGE; /* Format accepted */
|
||||
|
||||
frame = 1;
|
||||
if (im->frame_num > 0)
|
||||
frame = im->frame;
|
||||
if (frame > 0)
|
||||
{
|
||||
frame = im->frame_num;
|
||||
im->frame_count = spectre_document_get_n_pages(spdoc);
|
||||
D("Pages=%d\n", im->frame_count);
|
||||
|
||||
if (frame > 1 && frame > im->frame_count)
|
||||
QUIT_WITH_RC(LOAD_BADFRAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = 1;
|
||||
}
|
||||
|
||||
sppage = spectre_document_get_page(spdoc, frame - 1);
|
||||
spst = spectre_document_status(spdoc);
|
||||
|
|
|
@ -33,10 +33,9 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
rc = LOAD_BADIMAGE; /* Format accepted */
|
||||
|
||||
frame = 1;
|
||||
if (im->frame_num > 0)
|
||||
frame = im->frame;
|
||||
if (frame > 0)
|
||||
{
|
||||
frame = im->frame_num;
|
||||
im->frame_count = WebPDemuxGetI(demux, WEBP_FF_FRAME_COUNT);
|
||||
im->loop_count = WebPDemuxGetI(demux, WEBP_FF_LOOP_COUNT);
|
||||
if (im->frame_count > 1)
|
||||
|
@ -50,6 +49,10 @@ _load(ImlibImage * im, int load_data)
|
|||
if (frame > 1 && frame > im->frame_count)
|
||||
QUIT_WITH_RC(LOAD_BADFRAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = 1;
|
||||
}
|
||||
|
||||
if (!WebPDemuxGetFrame(demux, frame, &iter))
|
||||
goto quit;
|
||||
|
|
Loading…
Reference in New Issue