fix webp anim load

we were dropping the first frame and duplicating the last frame, thanks
to a < / <= mixup

see https://github.com/libvips/libvips/issues/1261
This commit is contained in:
John Cupitt 2019-04-16 16:54:47 +01:00
parent c351c665a1
commit 670d109a67
1 changed files with 12 additions and 3 deletions

View File

@ -450,7 +450,8 @@ read_header( Read *read, VipsImage *out )
vips_image_set_int( out, "gif-loop", loop_count );
vips_image_set_int( out, "page-height", read->frame_height );
/* We must get the first frame to get the delay.
/* We must get the first frame to get the delay. Frames number
* from 1.
*/
if( WebPDemuxGetFrame( read->demux, 1, &iter ) ) {
read->delay = iter.duration;
@ -460,8 +461,8 @@ read_header( Read *read, VipsImage *out )
#endif /*DEBUG*/
vips_image_set_int( out, "gif-delay", read->delay );
WebPDemuxReleaseIterator( &iter );
}
WebPDemuxReleaseIterator( &iter );
if( read->n == -1 )
read->n = read->frame_count - read->page;
@ -572,6 +573,10 @@ read_frame( Read *read,
{
VipsImage *frame;
#ifdef DEBUG
printf( "read_frame:\n" );
#endif /*DEBUG*/
frame = vips_image_new_memory();
vips_image_init_fields( frame,
width, height,
@ -604,6 +609,10 @@ read_next_frame( Read *read )
{
VipsImage *frame;
#ifdef DEBUG
printf( "read_next_frame:\n" );
#endif /*DEBUG*/
/* Dispose from the previous frame.
*/
if( read->dispose_method == WEBP_MUX_DISPOSE_BACKGROUND )
@ -690,7 +699,7 @@ read_webp_generate( VipsRegion *or,
g_assert( r->height == 1 );
while( read->frame_no <= frame ) {
while( read->frame_no < frame ) {
if( read_next_frame( read ) )
return( -1 );