From 20cb0da2476b55865a6f6d8310846cd6d002e508 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 11 Oct 2019 14:03:10 +0100 Subject: [PATCH] test suite passes with all jpegload coming via VipsStreamInput --- ChangeLog | 2 ++ libvips/foreign/jpeg2vips.c | 21 +++++++++++++++++++++ libvips/foreign/jpegload.c | 2 -- libvips/iofuncs/stream.c | 5 ++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 634d4f8a..3c5146b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ - add @interpretation and @format to rawload - nifti load/save uses double for all floating point metadata - add vips_error_buffer_copy() +- add VipsStream ... a universal IO class for loaders and savers +- jpegload uses the new IO class 31/8/19 started 8.8.3 - revert sharpen restoring the input colourspace diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index bbf15587..8948d408 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -250,6 +250,26 @@ stream_fill_input_buffer( j_decompress_ptr cinfo ) return( TRUE ); } +static void +skip_input_data( j_decompress_ptr cinfo, long num_bytes ) +{ + Source *src = (Source *) cinfo->src; + + if( num_bytes > 0 ) { + while (num_bytes > (long) src->pub.bytes_in_buffer) { + num_bytes -= (long) src->pub.bytes_in_buffer; + (void) (*src->pub.fill_input_buffer) (cinfo); + + /* note we assume that fill_input_buffer will never + * return FALSE, so suspension need not be handled. + */ + } + + src->pub.next_input_byte += (size_t) num_bytes; + src->pub.bytes_in_buffer -= (size_t) num_bytes; + } +} + static int readjpeg_open_input( ReadJpeg *jpeg ) { @@ -272,6 +292,7 @@ readjpeg_open_input( ReadJpeg *jpeg ) src->pub.init_source = stream_init_source; src->pub.fill_input_buffer = stream_fill_input_buffer; src->pub.resync_to_restart = jpeg_resync_to_restart; + src->pub.skip_input_data = skip_input_data; src->pub.bytes_in_buffer = 0; src->pub.next_input_byte = src->buf; } diff --git a/libvips/foreign/jpegload.c b/libvips/foreign/jpegload.c index 2960950c..5eb95794 100644 --- a/libvips/foreign/jpegload.c +++ b/libvips/foreign/jpegload.c @@ -197,8 +197,6 @@ vips_foreign_load_jpeg_stream_load( VipsForeignLoad *load ) static gboolean vips_foreign_load_jpeg_stream_is_a( VipsStreamInput *input ) { - printf( "vips_foreign_load_jpeg_stream_is_a:\n" ); - return( vips__isjpeg_stream( input ) ); } diff --git a/libvips/iofuncs/stream.c b/libvips/iofuncs/stream.c index 45b2f14a..d44e1aff 100644 --- a/libvips/iofuncs/stream.c +++ b/libvips/iofuncs/stream.c @@ -33,16 +33,19 @@ /* TODO * + * - filename encoding * - memory output * - add mmapable descriptors * - add seekable descriptors + * - can we test for mmapable and seekable? + * - do we need eof? * - can we really change all behaviour in the subclass? will we need map and * seek as well as read and rewind? */ /* - */ #define VIPS_DEBUG + */ #ifdef HAVE_CONFIG_H #include