check frame durations

This commit is contained in:
John Cupitt 2018-11-03 14:03:16 +00:00
parent 7071ad79a8
commit d317961378
1 changed files with 16 additions and 16 deletions

View File

@ -124,10 +124,6 @@ typedef struct {
*/ */
WebPDecoderConfig config; WebPDecoderConfig config;
/* Incremental decoder state.
*/
WebPIDecoder *idec;
/* Each decoded frame, as a vips memory image. /* Each decoded frame, as a vips memory image.
*/ */
GArray *frames; GArray *frames;
@ -173,7 +169,6 @@ read_free( Read *read )
} }
VIPS_FREEF( g_array_unref, read->frames ); VIPS_FREEF( g_array_unref, read->frames );
VIPS_FREEF( WebPIDelete, read->idec );
VIPS_FREEF( WebPDemuxDelete, read->demux ); VIPS_FREEF( WebPDemuxDelete, read->demux );
WebPFreeDecBuffer( &read->config.output ); WebPFreeDecBuffer( &read->config.output );
@ -209,7 +204,6 @@ read_new( const char *filename, const void *data, size_t length,
read->shrink = shrink; read->shrink = shrink;
read->delay = 100; read->delay = 100;
read->fd = 0; read->fd = 0;
read->idec = NULL;
read->demux = NULL; read->demux = NULL;
read->frames = NULL; read->frames = NULL;
@ -298,11 +292,13 @@ read_header( Read *read, VipsImage *out )
/* We must get the first frame to get the delay. /* We must get the first frame to get the delay.
*/ */
if( WebPDemuxGetFrame( read->demux, 1, &iter ) ) { if( WebPDemuxGetFrame( read->demux, 1, &iter ) ) {
read->delay = iter.duration;
#ifdef DEBUG #ifdef DEBUG
printf( "webp2vips: duration = %d\n", iter.duration ); printf( "webp2vips: duration = %d\n", read->delay );
#endif /*DEBUG*/ #endif /*DEBUG*/
vips_image_set_int( out, "gif-delay", iter.duration ); vips_image_set_int( out, "gif-delay", read->delay );
WebPDemuxReleaseIterator( &iter ); WebPDemuxReleaseIterator( &iter );
} }
@ -432,20 +428,24 @@ read_image( Read *read, VipsImage *out )
do { do {
VipsImage *frame; VipsImage *frame;
if( iter.duration != read->delay )
g_warning( "webp2vips: "
"not all frames have equal duration" );
#ifdef DEBUG #ifdef DEBUG
printf( "webp2vips: frame_num = %d\n", iter.frame_num ); printf( "webp2vips: frame_num = %d\n", iter.frame_num );
printf( "webp2vips: x_offset = %d\n", iter.x_offset ); printf( " x_offset = %d\n", iter.x_offset );
printf( "webp2vips: y_offset = %d\n", iter.y_offset ); printf( " y_offset = %d\n", iter.y_offset );
printf( "webp2vips: width = %d\n", iter.width ); printf( " width = %d\n", iter.width );
printf( "webp2vips: height = %d\n", iter.height ); printf( " height = %d\n", iter.height );
printf( "webp2vips: duration = %d\n", iter.duration ); printf( " duration = %d\n", iter.duration );
printf( "webp2vips: dispose = " ); printf( " dispose = " );
if( iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ) if( iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND )
printf( "clear to background\n" ); printf( "clear to background\n" );
else else
printf( "none\n" ); printf( "none\n" );
printf( "webp2vips: has_alpha = %d\n", iter.has_alpha ); printf( " has_alpha = %d\n", iter.has_alpha );
printf( "webp2vips: blend_method = " ); printf( " blend_method = " );
if( iter.blend_method == WEBP_MUX_BLEND ) if( iter.blend_method == WEBP_MUX_BLEND )
printf( "blend with previous\n" ); printf( "blend with previous\n" );
else else