minor nsgifload revisions
- add note to changelog - remove dead code - improve debug output - track current page number see https://github.com/libvips/libvips/pull/2699
This commit is contained in:
parent
eb577606a0
commit
f65b615a17
@ -14,6 +14,7 @@
|
|||||||
- edge antialiasing for mapim with @background, @extend and @premultiplied
|
- edge antialiasing for mapim with @background, @extend and @premultiplied
|
||||||
- add support for regions in C++ API [shado23]
|
- add support for regions in C++ API [shado23]
|
||||||
- add maxerror to gifsave [dloebl]
|
- add maxerror to gifsave [dloebl]
|
||||||
|
- update libnsgif API [tlsa]
|
||||||
|
|
||||||
26/11/21 started 8.12.3
|
26/11/21 started 8.12.3
|
||||||
- better arg checking for hist_find_ndim [travisbell]
|
- better arg checking for hist_find_ndim [travisbell]
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
*
|
*
|
||||||
* 6/10/18
|
* 6/10/18
|
||||||
* - from gifload.c
|
* - from gifload.c
|
||||||
|
* 3/3/22 tlsa
|
||||||
|
* - update libnsgif API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -63,10 +65,6 @@
|
|||||||
* - hard to detect mono images -- local_colour_table in libnsgif is only set
|
* - hard to detect mono images -- local_colour_table in libnsgif is only set
|
||||||
* when we decode a frame, so we can't tell just from init whether any
|
* when we decode a frame, so we can't tell just from init whether any
|
||||||
* frames have colour info
|
* frames have colour info
|
||||||
*
|
|
||||||
* - don't bother detecting alpha -- if we can't detect RGB, alpha won't help
|
|
||||||
* much
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_NSGIF
|
#ifdef HAVE_NSGIF
|
||||||
@ -129,6 +127,11 @@ typedef struct _VipsForeignLoadNsgif {
|
|||||||
*/
|
*/
|
||||||
gboolean has_transparency;
|
gboolean has_transparency;
|
||||||
|
|
||||||
|
/* The current frame bitmap and the frame number for it.
|
||||||
|
*/
|
||||||
|
nsgif_bitmap_t *bitmap;
|
||||||
|
int frame_number;
|
||||||
|
|
||||||
} VipsForeignLoadNsgif;
|
} VipsForeignLoadNsgif;
|
||||||
|
|
||||||
typedef VipsForeignLoadClass VipsForeignLoadNsgifClass;
|
typedef VipsForeignLoadClass VipsForeignLoadNsgifClass;
|
||||||
@ -136,19 +139,12 @@ typedef VipsForeignLoadClass VipsForeignLoadNsgifClass;
|
|||||||
G_DEFINE_ABSTRACT_TYPE( VipsForeignLoadNsgif, vips_foreign_load_nsgif,
|
G_DEFINE_ABSTRACT_TYPE( VipsForeignLoadNsgif, vips_foreign_load_nsgif,
|
||||||
VIPS_TYPE_FOREIGN_LOAD );
|
VIPS_TYPE_FOREIGN_LOAD );
|
||||||
|
|
||||||
static const char *
|
|
||||||
vips_foreign_load_nsgif_errstr( nsgif_error result )
|
|
||||||
{
|
|
||||||
return nsgif_strerror( result );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_nsgif_error( VipsForeignLoadNsgif *gif, nsgif_error result )
|
vips_foreign_load_nsgif_error( VipsForeignLoadNsgif *gif, nsgif_error result )
|
||||||
{
|
{
|
||||||
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( gif );
|
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( gif );
|
||||||
|
|
||||||
vips_error( class->nickname, "%s",
|
vips_error( class->nickname, "%s", nsgif_strerror( result ) );
|
||||||
vips_foreign_load_nsgif_errstr( result ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -198,23 +194,22 @@ vips_foreign_load_nsgif_is_a_source( VipsSource *source )
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_frame( const nsgif_frame_info_t *frame )
|
print_frame( const nsgif_frame_info_t *frame_info )
|
||||||
{
|
{
|
||||||
if ( frame == NULL )
|
if ( frame_info == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf( "frame:\n" );
|
printf( "frame_info:\n" );
|
||||||
printf( " display = %d\n", frame->display );
|
printf( " display = %d\n", frame_info->display );
|
||||||
printf( " delay = %d\n", frame->delay );
|
printf( " transparency = %d\n", frame_info->transparency );
|
||||||
// printf( " opaque = %d\n", frame->opaque );
|
|
||||||
printf( " disposal = %d (%s)\n",
|
printf( " disposal = %d (%s)\n",
|
||||||
frame->disposal, nsgif_str_disposal( frame->disposal ) );
|
frame_info->disposal,
|
||||||
printf( " transparency = %d\n", frame->transparency );
|
nsgif_str_disposal( frame_info->disposal ) );
|
||||||
// printf( " transparency_index = %d\n", frame->transparency_index );
|
printf( " delay = %d\n", frame_info->delay );
|
||||||
printf( " rect.x0 = %u\n", frame->rect.x0 );
|
printf( " rect.x0 = %u\n", frame_info->rect.x0 );
|
||||||
printf( " rect.y0 = %u\n", frame->rect.y0 );
|
printf( " rect.y0 = %u\n", frame_info->rect.y0 );
|
||||||
printf( " rect.x1 = %u\n", frame->rect.x1 );
|
printf( " rect.x1 = %u\n", frame_info->rect.x1 );
|
||||||
printf( " rect.y1 = %u\n", frame->rect.y1 );
|
printf( " rect.y1 = %u\n", frame_info->rect.y1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -226,17 +221,20 @@ print_animation( nsgif_t *anim, const nsgif_info_t *info )
|
|||||||
printf( " width = %d\n", info->width );
|
printf( " width = %d\n", info->width );
|
||||||
printf( " height = %d\n", info->height );
|
printf( " height = %d\n", info->height );
|
||||||
printf( " frame_count = %d\n", info->frame_count );
|
printf( " frame_count = %d\n", info->frame_count );
|
||||||
|
printf( " loop_max = %d\n", info->loop_max );
|
||||||
printf( " loop_count = %d\n", info->loop_count );
|
printf( " loop_count = %d\n", info->loop_count );
|
||||||
// printf( " colour_table_size = %d\n", anim->colour_table_size );
|
printf( " background = %d %d %d %d\n",
|
||||||
// printf( " global_colours = %d\n", anim->global_colours );
|
info->background[0],
|
||||||
// printf( " global_colour_table = %p\n", anim->global_colour_table );
|
info->background[1],
|
||||||
// printf( " local_colour_table = %p\n", anim->local_colour_table );
|
info->background[2],
|
||||||
|
info->background[3] );
|
||||||
|
|
||||||
for( i = 0; i < info->frame_count; i++ ) {
|
for( i = 0; i < info->frame_count; i++ ) {
|
||||||
printf( "%d ", i );
|
printf( "%d ", i );
|
||||||
print_frame( nsgif_get_frame_info( anim, i ) );
|
print_frame( nsgif_get_frame_info( anim, i ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*VERBOSE*/
|
#endif /*VERBOSE*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -386,8 +384,6 @@ static int
|
|||||||
vips_foreign_load_nsgif_generate( VipsRegion *or,
|
vips_foreign_load_nsgif_generate( VipsRegion *or,
|
||||||
void *seq, void *a, void *b, gboolean *stop )
|
void *seq, void *a, void *b, gboolean *stop )
|
||||||
{
|
{
|
||||||
int prev_page = -1;
|
|
||||||
nsgif_bitmap_t *bitmap;
|
|
||||||
VipsRect *r = &or->valid;
|
VipsRect *r = &or->valid;
|
||||||
VipsForeignLoadNsgif *gif = (VipsForeignLoadNsgif *) a;
|
VipsForeignLoadNsgif *gif = (VipsForeignLoadNsgif *) a;
|
||||||
|
|
||||||
@ -410,21 +406,24 @@ vips_foreign_load_nsgif_generate( VipsRegion *or,
|
|||||||
g_assert( line >= 0 && line < gif->info->height );
|
g_assert( line >= 0 && line < gif->info->height );
|
||||||
g_assert( page >= 0 && page < gif->info->frame_count );
|
g_assert( page >= 0 && page < gif->info->frame_count );
|
||||||
|
|
||||||
if( prev_page != page ) {
|
if( gif->frame_number != page ) {
|
||||||
result = nsgif_frame_decode( gif->anim, page, &bitmap );
|
result = nsgif_frame_decode( gif->anim,
|
||||||
|
page, &gif->bitmap );
|
||||||
VIPS_DEBUG_MSG( " nsgif_frame_decode(%d) = %d\n",
|
VIPS_DEBUG_MSG( " nsgif_frame_decode(%d) = %d\n",
|
||||||
page, result );
|
page, result );
|
||||||
if( result != NSGIF_OK ) {
|
if( result != NSGIF_OK ) {
|
||||||
vips_foreign_load_nsgif_error( gif, result );
|
vips_foreign_load_nsgif_error( gif, result );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
print_animation( gif->anim );
|
print_frame( nsgif_get_frame_info( gif->anim, page ) );
|
||||||
#endif /*VERBOSE*/
|
#endif /*VERBOSE*/
|
||||||
prev_page = page;
|
|
||||||
|
gif->frame_number = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = bitmap + line * gif->info->width * sizeof( int );
|
p = gif->bitmap + line * gif->info->width * sizeof( int );
|
||||||
q = VIPS_REGION_ADDR( or, 0, r->top + y );
|
q = VIPS_REGION_ADDR( or, 0, r->top + y );
|
||||||
if( gif->has_transparency )
|
if( gif->has_transparency )
|
||||||
memcpy( q, p, VIPS_REGION_SIZEOF_LINE( or ) );
|
memcpy( q, p, VIPS_REGION_SIZEOF_LINE( or ) );
|
||||||
@ -564,7 +563,10 @@ vips_foreign_load_nsgif_init( VipsForeignLoadNsgif *gif )
|
|||||||
nsgif_strerror( result ) );
|
nsgif_strerror( result ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gif->n = 1;
|
gif->n = 1;
|
||||||
|
gif->frame_number = -1;
|
||||||
|
gif->bitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _VipsForeignLoadNsgifFile {
|
typedef struct _VipsForeignLoadNsgifFile {
|
||||||
|
Loading…
Reference in New Issue
Block a user