Skip to content

cgifsave: Make loop counts more accurate #2709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 10, 2022
Merged
8 changes: 8 additions & 0 deletions libvips/foreign/cgifsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,19 @@ vips_foreign_save_cgif_write_frame( VipsForeignSaveCgif *cgif )
*/
if( !cgif->cgif_context ) {
cgif->cgif_config.pGlobalPalette = cgif->palette_rgb;
#ifdef HAVE_CGIF_ATTR_NO_LOOP
cgif->cgif_config.attrFlags = CGIF_ATTR_IS_ANIMATED | ( cgif->loop == 1 ? CGIF_ATTR_NO_LOOP : 0 );
#else
cgif->cgif_config.attrFlags = CGIF_ATTR_IS_ANIMATED;
#endif/*HAVE_CGIF_ATTR_NO_LOOP*/
cgif->cgif_config.width = frame_rect->width;
cgif->cgif_config.height = frame_rect->height;
cgif->cgif_config.numGlobalPaletteEntries = cgif->lp->count;
#ifdef HAVE_CGIF_ATTR_NO_LOOP
cgif->cgif_config.numLoops = cgif->loop > 1 ? cgif->loop - 1 : cgif->loop;
#else
cgif->cgif_config.numLoops = cgif->loop;
#endif/*HAVE_CGIF_ATTR_NO_LOOP*/
cgif->cgif_config.pWriteFn = vips__cgif_write;
cgif->cgif_config.pContext = (void *) cgif->target;

Expand Down
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ if quantisation_package.found()
if cgif_dep.found()
libvips_deps += cgif_dep
cfg_var.set('HAVE_CGIF', '1')
if cc.compiles('#include <cgif.h>\nint i = CGIF_ATTR_NO_LOOP;', name: 'Has CGIF_ATTR_NO_LOOP', dependencies: cgif_dep)
cfg_var.set('HAVE_CGIF_ATTR_NO_LOOP', '1')
endif
endif
endif

Expand Down