Skip to content

Commit c33d2a2

Browse files
committed
cgifsave: fix palettes comparison
1 parent e4271e1 commit c33d2a2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

libvips/foreign/cgifsave.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ vips_foreign_save_cgif_set_transparent( VipsForeignSaveCgif *cgif,
219219
}
220220
}
221221

222-
static int
222+
static double
223223
vips__cgif_compare_palettes( const VipsQuantisePalette *new,
224224
const VipsQuantisePalette *old )
225225
{
226226
int i, j;
227-
int best_dist, dist, rd, gd, bd;
228-
int total_dist;
227+
double best_dist, dist, rd, gd, bd;
228+
double total_dist;
229229

230230
g_assert( new->count <= 256 );
231231
g_assert( old->count <= 256 );
@@ -337,16 +337,16 @@ vips_foreign_save_cgif_pick_quantiser( VipsForeignSaveCgif *cgif,
337337
const VipsQuantisePalette *prev = vips__quantise_get_palette(
338338
cgif->previous_quantisation_result );
339339

340-
int global_diff = vips__cgif_compare_palettes( this, global );
341-
int prev_diff = ( prev == global ) ? global_diff :
340+
double global_diff = vips__cgif_compare_palettes( this, global );
341+
double prev_diff = ( prev == global ) ? global_diff :
342342
vips__cgif_compare_palettes( this, prev );
343343

344344
#ifdef DEBUG_VERBOSE
345345
printf( "vips_foreign_save_cgif_write_frame: "
346-
"this -> global distance = %d\n",
346+
"this -> global distance = %g\n",
347347
global_diff );
348348
printf( "vips_foreign_save_cgif_write_frame: "
349-
"this -> prev distance = %d\n",
349+
"this -> prev distance = %g\n",
350350
prev_diff );
351351
printf( "vips_foreign_save_cgif_write_frame: "
352352
"threshold = %g\n", cgif->interpalette_maxerror );
@@ -864,7 +864,7 @@ vips_foreign_save_cgif_class_init( VipsForeignSaveCgifClass *class )
864864
_( "Maximum inter-palette error for palette reusage" ),
865865
VIPS_ARGUMENT_OPTIONAL_INPUT,
866866
G_STRUCT_OFFSET( VipsForeignSaveCgif, interpalette_maxerror ),
867-
0, 256, 40.0 );
867+
0, 256, 3.0 );
868868
}
869869

870870
static void
@@ -875,7 +875,7 @@ vips_foreign_save_cgif_init( VipsForeignSaveCgif *gif )
875875
gif->bitdepth = 8;
876876
gif->interframe_maxerror = 0.0;
877877
gif->reoptimise = FALSE;
878-
gif->interpalette_maxerror = 40.0;
878+
gif->interpalette_maxerror = 3.0;
879879
gif->mode = VIPS_FOREIGN_SAVE_CGIF_MODE_GLOBAL;
880880
}
881881

0 commit comments

Comments
 (0)